Kaynağa Gözat

migration fix

master
Daniel 2 yıl önce
ebeveyn
işleme
bbf9fa97c8
5 değiştirilmiş dosya ile 463 ekleme ve 62 silme
  1. +13
    -1
      migrations/Version20240216094550.php
  2. +445
    -60
      openapi.yaml
  3. +3
    -0
      src/ApiResource/CommentApi.php
  4. +1
    -0
      src/Mapper/CommentEntityToApiMapper.php
  5. +1
    -1
      src/Mapper/PostingEntityToApiMapper.php

migrations/Version20240215093709.php → migrations/Version20240216094550.php Dosyayı Görüntüle

@@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240215093709 extends AbstractMigration
final class Version20240216094550 extends AbstractMigration
{
public function getDescription(): string
{
@@ -21,10 +21,16 @@ final class Version20240215093709 extends AbstractMigration
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE comment (id INT AUTO_INCREMENT NOT NULL, owner_id INT NOT NULL, posting_id INT NOT NULL, message LONGTEXT NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_9474526C7E3C61F9 (owner_id), INDEX IDX_9474526C9AE985F6 (posting_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE contact (id INT AUTO_INCREMENT NOT NULL, partner_id INT NOT NULL, image_id INT DEFAULT NULL, first_name VARCHAR(255) NOT NULL, last_name VARCHAR(255) NOT NULL, birthday DATE DEFAULT NULL, position VARCHAR(255) DEFAULT NULL, phone VARCHAR(255) DEFAULT NULL, email VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_4C62E6389393F8FE (partner_id), INDEX IDX_4C62E6383DA5256D (image_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE media_object (id INT AUTO_INCREMENT NOT NULL, file_path VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE partner (id INT AUTO_INCREMENT NOT NULL, logo_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, type VARCHAR(255) NOT NULL, street VARCHAR(255) DEFAULT NULL, street_no VARCHAR(255) DEFAULT NULL, zip VARCHAR(255) DEFAULT NULL, city VARCHAR(255) DEFAULT NULL, country VARCHAR(255) DEFAULT NULL, website VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_312B3E16F98F144A (logo_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE posting (id INT AUTO_INCREMENT NOT NULL, owner_id INT NOT NULL, partner_id INT NOT NULL, contact_id INT DEFAULT NULL, headline VARCHAR(255) NOT NULL, message LONGTEXT NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_BD275D737E3C61F9 (owner_id), INDEX IDX_BD275D739393F8FE (partner_id), INDEX IDX_BD275D73E7A1254A (contact_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE `user` (id INT AUTO_INCREMENT NOT NULL, email VARCHAR(180) NOT NULL, first_name VARCHAR(255) NOT NULL, last_name VARCHAR(255) NOT NULL, roles JSON NOT NULL COMMENT \'(DC2Type:json)\', password VARCHAR(255) NOT NULL, active TINYINT(1) NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', UNIQUE INDEX UNIQ_8D93D649E7927C74 (email), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE comment ADD CONSTRAINT FK_9474526C7E3C61F9 FOREIGN KEY (owner_id) REFERENCES `user` (id)');
$this->addSql('ALTER TABLE comment ADD CONSTRAINT FK_9474526C9AE985F6 FOREIGN KEY (posting_id) REFERENCES posting (id)');
$this->addSql('ALTER TABLE contact ADD CONSTRAINT FK_4C62E6389393F8FE FOREIGN KEY (partner_id) REFERENCES partner (id)');
$this->addSql('ALTER TABLE contact ADD CONSTRAINT FK_4C62E6383DA5256D FOREIGN KEY (image_id) REFERENCES media_object (id)');
$this->addSql('ALTER TABLE partner ADD CONSTRAINT FK_312B3E16F98F144A FOREIGN KEY (logo_id) REFERENCES media_object (id)');
$this->addSql('ALTER TABLE posting ADD CONSTRAINT FK_BD275D737E3C61F9 FOREIGN KEY (owner_id) REFERENCES `user` (id)');
$this->addSql('ALTER TABLE posting ADD CONSTRAINT FK_BD275D739393F8FE FOREIGN KEY (partner_id) REFERENCES partner (id)');
$this->addSql('ALTER TABLE posting ADD CONSTRAINT FK_BD275D73E7A1254A FOREIGN KEY (contact_id) REFERENCES contact (id)');
@@ -35,10 +41,16 @@ final class Version20240215093709 extends AbstractMigration
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE comment DROP FOREIGN KEY FK_9474526C7E3C61F9');
$this->addSql('ALTER TABLE comment DROP FOREIGN KEY FK_9474526C9AE985F6');
$this->addSql('ALTER TABLE contact DROP FOREIGN KEY FK_4C62E6389393F8FE');
$this->addSql('ALTER TABLE contact DROP FOREIGN KEY FK_4C62E6383DA5256D');
$this->addSql('ALTER TABLE partner DROP FOREIGN KEY FK_312B3E16F98F144A');
$this->addSql('ALTER TABLE posting DROP FOREIGN KEY FK_BD275D737E3C61F9');
$this->addSql('ALTER TABLE posting DROP FOREIGN KEY FK_BD275D739393F8FE');
$this->addSql('ALTER TABLE posting DROP FOREIGN KEY FK_BD275D73E7A1254A');
$this->addSql('DROP TABLE comment');
$this->addSql('DROP TABLE contact');
$this->addSql('DROP TABLE media_object');
$this->addSql('DROP TABLE partner');
$this->addSql('DROP TABLE posting');
$this->addSql('DROP TABLE `user`');
}

+ 445
- 60
openapi.yaml Dosyayı Görüntüle

@@ -8,6 +8,239 @@ servers:
url: /
description: ''
paths:
/api/comments:
get:
operationId: api_comments_get_collection
tags:
- Comment
responses:
200:
description: 'Comment collection'
content:
application/ld+json:
schema:
type: object
properties:
'hydra:member': { type: array, items: { $ref: '#/components/schemas/Comment.jsonld' } }
'hydra:totalItems': { type: integer, minimum: 0 }
'hydra:view': { type: object, properties: { '@id': { type: string, format: iri-reference }, '@type': { type: string }, 'hydra:first': { type: string, format: iri-reference }, 'hydra:last': { type: string, format: iri-reference }, 'hydra:previous': { type: string, format: iri-reference }, 'hydra:next': { type: string, format: iri-reference } }, example: { '@id': string, type: string, 'hydra:first': string, 'hydra:last': string, 'hydra:previous': string, 'hydra:next': string } }
'hydra:search': { type: object, properties: { '@type': { type: string }, 'hydra:template': { type: string }, 'hydra:variableRepresentation': { type: string }, 'hydra:mapping': { type: array, items: { type: object, properties: { '@type': { type: string }, variable: { type: string }, property: { type: [string, 'null'] }, required: { type: boolean } } } } } }
required:
- 'hydra:member'
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Comment'
text/html:
schema:
type: array
items:
$ref: '#/components/schemas/Comment'
application/hal+json:
schema:
type: object
properties:
_embedded: { type: array, items: { $ref: '#/components/schemas/Comment.jsonhal' } }
totalItems: { type: integer, minimum: 0 }
itemsPerPage: { type: integer, minimum: 0 }
_links: { type: object, properties: { self: { type: object, properties: { href: { type: string, format: iri-reference } } }, first: { type: object, properties: { href: { type: string, format: iri-reference } } }, last: { type: object, properties: { href: { type: string, format: iri-reference } } }, next: { type: object, properties: { href: { type: string, format: iri-reference } } }, previous: { type: object, properties: { href: { type: string, format: iri-reference } } } } }
required:
- _links
- _embedded
summary: 'Retrieves the collection of Comment resources.'
description: 'Retrieves the collection of Comment resources.'
parameters:
-
name: page
in: query
description: 'The collection page number'
required: false
deprecated: false
allowEmptyValue: true
schema:
type: integer
default: 1
style: form
explode: false
allowReserved: false
-
name: itemsPerPage
in: query
description: 'The number of items per page'
required: false
deprecated: false
allowEmptyValue: true
schema:
type: integer
default: 10
minimum: 0
maximum: 50
style: form
explode: false
allowReserved: false
deprecated: false
post:
operationId: api_comments_post
tags:
- Comment
responses:
201:
description: 'Comment resource created'
content:
application/ld+json:
schema:
$ref: '#/components/schemas/Comment.jsonld'
application/json:
schema:
$ref: '#/components/schemas/Comment'
text/html:
schema:
$ref: '#/components/schemas/Comment'
application/hal+json:
schema:
$ref: '#/components/schemas/Comment.jsonhal'
links: { }
400:
description: 'Invalid input'
422:
description: 'Unprocessable entity'
summary: 'Creates a Comment resource.'
description: 'Creates a Comment resource.'
parameters: []
requestBody:
description: 'The new Comment resource'
content:
application/ld+json:
schema:
$ref: '#/components/schemas/Comment.jsonld'
application/json:
schema:
$ref: '#/components/schemas/Comment'
text/html:
schema:
$ref: '#/components/schemas/Comment'
application/hal+json:
schema:
$ref: '#/components/schemas/Comment.jsonhal'
required: true
deprecated: false
parameters: []
'/api/comments/{id}':
get:
operationId: api_comments_id_get
tags:
- Comment
responses:
200:
description: 'Comment resource'
content:
application/ld+json:
schema:
$ref: '#/components/schemas/Comment.jsonld'
application/json:
schema:
$ref: '#/components/schemas/Comment'
text/html:
schema:
$ref: '#/components/schemas/Comment'
application/hal+json:
schema:
$ref: '#/components/schemas/Comment.jsonhal'
404:
description: 'Resource not found'
summary: 'Retrieves a Comment resource.'
description: 'Retrieves a Comment resource.'
parameters:
-
name: id
in: path
description: 'CommentApi identifier'
required: true
deprecated: false
allowEmptyValue: false
schema:
type: string
style: simple
explode: false
allowReserved: false
deprecated: false
delete:
operationId: api_comments_id_delete
tags:
- Comment
responses:
204:
description: 'Comment resource deleted'
404:
description: 'Resource not found'
summary: 'Removes the Comment resource.'
description: 'Removes the Comment resource.'
parameters:
-
name: id
in: path
description: 'CommentApi identifier'
required: true
deprecated: false
allowEmptyValue: false
schema:
type: string
style: simple
explode: false
allowReserved: false
deprecated: false
patch:
operationId: api_comments_id_patch
tags:
- Comment
responses:
200:
description: 'Comment resource updated'
content:
application/ld+json:
schema:
$ref: '#/components/schemas/Comment.jsonld'
application/json:
schema:
$ref: '#/components/schemas/Comment'
text/html:
schema:
$ref: '#/components/schemas/Comment'
application/hal+json:
schema:
$ref: '#/components/schemas/Comment.jsonhal'
links: { }
400:
description: 'Invalid input'
422:
description: 'Unprocessable entity'
404:
description: 'Resource not found'
summary: 'Updates the Comment resource.'
description: 'Updates the Comment resource.'
parameters:
-
name: id
in: path
description: 'CommentApi identifier'
required: true
deprecated: false
allowEmptyValue: false
schema:
type: string
style: simple
explode: false
allowReserved: false
requestBody:
description: 'The updated Comment resource'
content:
application/merge-patch+json:
schema:
$ref: '#/components/schemas/Comment'
required: true
deprecated: false
parameters: []
/api/contacts:
get:
operationId: api_contacts_get_collection
@@ -1255,6 +1488,140 @@ paths:
parameters: []
components:
schemas:
Comment:
type: object
description: ''
deprecated: false
required:
- message
properties:
message:
type:
- string
- 'null'
owner:
type:
- string
- 'null'
format: iri-reference
example: 'https://example.com/'
ownerName:
readOnly: true
type:
- string
- 'null'
posting:
type:
- string
- 'null'
format: iri-reference
example: 'https://example.com/'
createdAt:
readOnly: true
type:
- string
- 'null'
format: date-time
Comment.jsonhal:
type: object
description: ''
deprecated: false
required:
- message
properties:
_links:
type: object
properties:
self:
type: object
properties:
href:
type: string
format: iri-reference
message:
type:
- string
- 'null'
owner:
type:
- string
- 'null'
format: iri-reference
example: 'https://example.com/'
ownerName:
readOnly: true
type:
- string
- 'null'
posting:
type:
- string
- 'null'
format: iri-reference
example: 'https://example.com/'
createdAt:
readOnly: true
type:
- string
- 'null'
format: date-time
Comment.jsonld:
type: object
description: ''
deprecated: false
required:
- message
properties:
'@context':
readOnly: true
oneOf:
-
type: string
-
type: object
properties:
'@vocab':
type: string
hydra:
type: string
enum: ['http://www.w3.org/ns/hydra/core#']
required:
- '@vocab'
- hydra
additionalProperties: true
'@id':
readOnly: true
type: string
'@type':
readOnly: true
type: string
message:
type:
- string
- 'null'
owner:
type:
- string
- 'null'
format: iri-reference
example: 'https://example.com/'
ownerName:
readOnly: true
type:
- string
- 'null'
posting:
type:
- string
- 'null'
format: iri-reference
example: 'https://example.com/'
createdAt:
readOnly: true
type:
- string
- 'null'
format: date-time
Contact:
type: object
description: ''
@@ -1272,7 +1639,6 @@ components:
- string
- 'null'
partner:
'owl:maxCardinality': 1
type:
- string
- 'null'
@@ -1284,7 +1650,6 @@ components:
- 'null'
format: date-time
image:
'owl:maxCardinality': 1
type:
- string
- 'null'
@@ -1307,6 +1672,12 @@ components:
type:
- string
- 'null'
postings:
type: array
items:
type: string
format: iri-reference
example: 'https://example.com/'
createdAt:
type:
- string
@@ -1338,7 +1709,6 @@ components:
- string
- 'null'
partner:
'owl:maxCardinality': 1
type:
- string
- 'null'
@@ -1350,7 +1720,6 @@ components:
- 'null'
format: date-time
image:
'owl:maxCardinality': 1
type:
- string
- 'null'
@@ -1373,6 +1742,12 @@ components:
type:
- string
- 'null'
postings:
type: array
items:
type: string
format: iri-reference
example: 'https://example.com/'
createdAt:
type:
- string
@@ -1418,7 +1793,6 @@ components:
- string
- 'null'
partner:
'owl:maxCardinality': 1
type:
- string
- 'null'
@@ -1430,7 +1804,6 @@ components:
- 'null'
format: date-time
image:
'owl:maxCardinality': 1
type:
- string
- 'null'
@@ -1453,6 +1826,12 @@ components:
type:
- string
- 'null'
postings:
type: array
items:
type: string
format: iri-reference
example: 'https://example.com/'
createdAt:
type:
- string
@@ -1570,7 +1949,6 @@ components:
- string
- 'null'
logo:
'owl:maxCardinality': 1
type:
- string
- 'null'
@@ -1642,7 +2020,6 @@ components:
- string
- 'null'
logo:
'owl:maxCardinality': 1
type:
- string
- 'null'
@@ -1728,7 +2105,6 @@ components:
- string
- 'null'
logo:
'owl:maxCardinality': 1
type:
- string
- 'null'
@@ -1767,7 +2143,6 @@ components:
- string
- 'null'
owner:
'owl:maxCardinality': 1
type:
- string
- 'null'
@@ -1779,17 +2154,21 @@ components:
- string
- 'null'
partner:
anyOf:
-
$ref: '#/components/schemas/Partner'
-
type: 'null'
type:
- string
- 'null'
format: iri-reference
example: 'https://example.com/'
contact:
anyOf:
-
$ref: '#/components/schemas/Contact'
-
type: 'null'
type:
- string
- 'null'
format: iri-reference
example: 'https://example.com/'
comments:
type: array
items:
$ref: '#/components/schemas/Comment'
createdAt:
readOnly: true
type:
@@ -1822,7 +2201,6 @@ components:
- string
- 'null'
owner:
'owl:maxCardinality': 1
type:
- string
- 'null'
@@ -1834,17 +2212,21 @@ components:
- string
- 'null'
partner:
anyOf:
-
$ref: '#/components/schemas/Partner.jsonhal'
-
type: 'null'
type:
- string
- 'null'
format: iri-reference
example: 'https://example.com/'
contact:
anyOf:
-
$ref: '#/components/schemas/Contact.jsonhal'
-
type: 'null'
type:
- string
- 'null'
format: iri-reference
example: 'https://example.com/'
comments:
type: array
items:
$ref: '#/components/schemas/Comment.jsonhal'
createdAt:
readOnly: true
type:
@@ -1891,7 +2273,6 @@ components:
- string
- 'null'
owner:
'owl:maxCardinality': 1
type:
- string
- 'null'
@@ -1903,17 +2284,21 @@ components:
- string
- 'null'
partner:
anyOf:
-
$ref: '#/components/schemas/Partner.jsonld'
-
type: 'null'
type:
- string
- 'null'
format: iri-reference
example: 'https://example.com/'
contact:
anyOf:
-
$ref: '#/components/schemas/Contact.jsonld'
-
type: 'null'
type:
- string
- 'null'
format: iri-reference
example: 'https://example.com/'
comments:
type: array
items:
$ref: '#/components/schemas/Comment.jsonld'
createdAt:
readOnly: true
type:
@@ -1952,18 +2337,18 @@ components:
- 'null'
active:
type: boolean
createdAt:
readOnly: true
type:
- string
- 'null'
format: date-time
postings:
type: array
items:
type: string
format: iri-reference
example: 'https://example.com/'
createdAt:
readOnly: true
type:
- string
- 'null'
format: date-time
User.jsonhal:
type: object
description: ''
@@ -2005,18 +2390,18 @@ components:
- 'null'
active:
type: boolean
createdAt:
readOnly: true
type:
- string
- 'null'
format: date-time
postings:
type: array
items:
type: string
format: iri-reference
example: 'https://example.com/'
createdAt:
readOnly: true
type:
- string
- 'null'
format: date-time
User.jsonld:
type: object
description: ''
@@ -2072,18 +2457,18 @@ components:
- 'null'
active:
type: boolean
createdAt:
readOnly: true
type:
- string
- 'null'
format: date-time
postings:
type: array
items:
type: string
format: iri-reference
example: 'https://example.com/'
createdAt:
readOnly: true
type:
- string
- 'null'
format: date-time
responses: { }
parameters: { }
examples: { }


+ 3
- 0
src/ApiResource/CommentApi.php Dosyayı Görüntüle

@@ -57,6 +57,9 @@ class CommentApi
#[IsValidOwner]
public ?UserApi $owner = null;

#[ApiProperty(writable: false)]
public ?string $ownerName = null;

public ?PostingApi $posting = null;

#[ApiProperty(writable: false)]


+ 1
- 0
src/Mapper/CommentEntityToApiMapper.php Dosyayı Görüntüle

@@ -43,6 +43,7 @@ class CommentEntityToApiMapper implements MapperInterface
$dto->owner = $this->microMapper->map($entity->getOwner(), UserApi::class, [
MicroMapperInterface::MAX_DEPTH => 0,
]);
$dto->ownerName = $entity->getOwner()?->getFirstName()." ".$entity->getOwner()?->getLastName();

$dto->posting = $this->microMapper->map($entity->getPosting(), PostingApi::class, [
MicroMapperInterface::MAX_DEPTH => 0,


+ 1
- 1
src/Mapper/PostingEntityToApiMapper.php Dosyayı Görüntüle

@@ -63,7 +63,7 @@ class PostingEntityToApiMapper implements MapperInterface
MicroMapperInterface::MAX_DEPTH => 1,
]);
}, $entity->getComments()->getValues());
//dd($dto);
$dto->createdAt = $entity->getCreatedAt();

return $dto;


Yükleniyor…
İptal
Kaydet