diff --git a/migrations/Version20220520130832.php b/migrations/Version20220520130832.php new file mode 100644 index 0000000..35309c9 --- /dev/null +++ b/migrations/Version20220520130832.php @@ -0,0 +1,32 @@ +addSql('CREATE TABLE file (id INT AUTO_INCREMENT NOT NULL, book_id INT NOT NULL, file_name VARCHAR(255) NOT NULL, file_size INT NOT NULL, extension VARCHAR(255) NOT NULL, type VARCHAR(255) NOT NULL, INDEX IDX_8C9F361016A2B381 (book_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('ALTER TABLE file ADD CONSTRAINT FK_8C9F361016A2B381 FOREIGN KEY (book_id) REFERENCES book (id)'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('DROP TABLE file'); + } +} diff --git a/src/Entity/Book.php b/src/Entity/Book.php index b9f9a01..7748904 100644 --- a/src/Entity/Book.php +++ b/src/Entity/Book.php @@ -30,12 +30,6 @@ class Book #[ORM\Column(type: 'date', nullable: true)] private $publish_date; - #[ORM\Column(type: 'string', length: 255, nullable: true)] - private $filename; - - #[ORM\Column(type: 'string', length: 255, nullable: true)] - private $original_filename; - #[ORM\Column(type: 'string', length: 255, nullable: true)] private $subtitle; @@ -112,30 +106,6 @@ class Book return $this; } - public function getFilename(): ?string - { - return $this->filename; - } - - public function setFilename(?string $filename): self - { - $this->filename = $filename; - - return $this; - } - - public function getOriginalFilename(): ?string - { - return $this->original_filename; - } - - public function setOriginalFilename(?string $original_filename): self - { - $this->original_filename = $original_filename; - - return $this; - } - public function getSubtitle(): ?string { return $this->subtitle;