migrations/Version20220710215225.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. /**
  7.  * Auto-generated Migration: Please modify to your needs!
  8.  */
  9. final class Version20220710215225 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         // this up() migration is auto-generated, please modify it to your needs
  18.         $this->addSql('CREATE TABLE recipe (id INT AUTO_INCREMENT NOT NULL, is_hot TINYINT(1) NOT NULL, is_locked TINYINT(1) NOT NULL, is_portion TINYINT(1) NOT NULL, image_path VARCHAR(255) DEFAULT NULL, is_deleted TINYINT(1) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
  19.         $this->addSql('CREATE TABLE recipe_ingredient (id INT AUTO_INCREMENT NOT NULL, recipe_id INT NOT NULL, ingredient_id INT NOT NULL, unit_id INT DEFAULT NULL, quantity NUMERIC(10, 4) NOT NULL, INDEX IDX_22D1FE1359D8A214 (recipe_id), INDEX IDX_22D1FE13933FE08C (ingredient_id), INDEX IDX_22D1FE13F8BD700D (unit_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
  20.         $this->addSql('CREATE TABLE recipe_step (id INT AUTO_INCREMENT NOT NULL, recipe_id INT NOT NULL, action_id INT DEFAULT NULL, workstation_id INT DEFAULT NULL, ingredient_id INT DEFAULT NULL, position INT NOT NULL, INDEX IDX_3CA2A4E359D8A214 (recipe_id), INDEX IDX_3CA2A4E39D32F035 (action_id), INDEX IDX_3CA2A4E3E29BB7D (workstation_id), INDEX IDX_3CA2A4E3933FE08C (ingredient_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
  21.         $this->addSql('CREATE TABLE recipe_step_translation (id INT AUTO_INCREMENT NOT NULL, recipe_step_id INT NOT NULL, lang VARCHAR(4) NOT NULL, name VARCHAR(255) DEFAULT NULL, description LONGTEXT DEFAULT NULL, INDEX IDX_F1D306693F5610DC (recipe_step_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
  22.         $this->addSql('CREATE TABLE recipe_translation (id INT AUTO_INCREMENT NOT NULL, recipe_id INT NOT NULL, lang VARCHAR(4) NOT NULL, name VARCHAR(255) DEFAULT NULL, kitchen_note LONGTEXT DEFAULT NULL, packing_note LONGTEXT DEFAULT NULL, dietitians_note LONGTEXT DEFAULT NULL, INDEX IDX_609B0B0B59D8A214 (recipe_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
  23.         $this->addSql('ALTER TABLE recipe_ingredient ADD CONSTRAINT FK_22D1FE1359D8A214 FOREIGN KEY (recipe_id) REFERENCES recipe (id)');
  24.         $this->addSql('ALTER TABLE recipe_ingredient ADD CONSTRAINT FK_22D1FE13933FE08C FOREIGN KEY (ingredient_id) REFERENCES ingredient_form (id)');
  25.         $this->addSql('ALTER TABLE recipe_ingredient ADD CONSTRAINT FK_22D1FE13F8BD700D FOREIGN KEY (unit_id) REFERENCES unit (id)');
  26.         $this->addSql('ALTER TABLE recipe_step ADD CONSTRAINT FK_3CA2A4E359D8A214 FOREIGN KEY (recipe_id) REFERENCES recipe (id)');
  27.         $this->addSql('ALTER TABLE recipe_step ADD CONSTRAINT FK_3CA2A4E39D32F035 FOREIGN KEY (action_id) REFERENCES action (id)');
  28.         $this->addSql('ALTER TABLE recipe_step ADD CONSTRAINT FK_3CA2A4E3E29BB7D FOREIGN KEY (workstation_id) REFERENCES workstation (id)');
  29.         $this->addSql('ALTER TABLE recipe_step ADD CONSTRAINT FK_3CA2A4E3933FE08C FOREIGN KEY (ingredient_id) REFERENCES ingredient_form (id)');
  30.         $this->addSql('ALTER TABLE recipe_step_translation ADD CONSTRAINT FK_F1D306693F5610DC FOREIGN KEY (recipe_step_id) REFERENCES recipe_step (id)');
  31.         $this->addSql('ALTER TABLE recipe_translation ADD CONSTRAINT FK_609B0B0B59D8A214 FOREIGN KEY (recipe_id) REFERENCES recipe (id)');
  32.     }
  33.     public function down(Schema $schema): void
  34.     {
  35.         // this down() migration is auto-generated, please modify it to your needs
  36.         $this->addSql('ALTER TABLE recipe_ingredient DROP FOREIGN KEY FK_22D1FE1359D8A214');
  37.         $this->addSql('ALTER TABLE recipe_step DROP FOREIGN KEY FK_3CA2A4E359D8A214');
  38.         $this->addSql('ALTER TABLE recipe_translation DROP FOREIGN KEY FK_609B0B0B59D8A214');
  39.         $this->addSql('ALTER TABLE recipe_step_translation DROP FOREIGN KEY FK_F1D306693F5610DC');
  40.         $this->addSql('DROP TABLE recipe');
  41.         $this->addSql('DROP TABLE recipe_ingredient');
  42.         $this->addSql('DROP TABLE recipe_step');
  43.         $this->addSql('DROP TABLE recipe_step_translation');
  44.         $this->addSql('DROP TABLE recipe_translation');
  45.     }
  46. }