<?php
declare (strict_types = 1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20190911162953 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('CREATE TABLE ingredient (`id` INT AUTO_INCREMENT NOT NULL, `name` VARCHAR(255) NOT NULL, `description` VARCHAR(4000) DEFAULT NULL, `note` VARCHAR(4000) DEFAULT NULL, `um_type` VARCHAR(255) DEFAULT NULL COMMENT \'(DC2Type:um_type)\', `value` INT DEFAULT NULL, `create_user` VARCHAR(50) NOT NULL, `creation_date` DATETIME NOT NULL, `modified_user` VARCHAR(50) DEFAULT NULL, `modified_date` DATETIME DEFAULT NULL, `image` LONGBLOB DEFAULT NULL, PRIMARY KEY(`id`)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE ingredient_alternative (ingredient_a_id INT NOT NULL, ingredient_b_id INT NOT NULL, INDEX IDX_B68C9363658FE3CE (ingredient_a_id), INDEX IDX_B68C9363773A4C20 (ingredient_b_id), PRIMARY KEY(ingredient_a_id, ingredient_b_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE ingredient_document (`id` INT AUTO_INCREMENT NOT NULL, `ingredient_id` INT NOT NULL, `document_id` INT NOT NULL, INDEX IDX_AA6FDAF83F7B41FD (`ingredient_id`), INDEX IDX_AA6FDAF85D9C4E11 (`document_id`), PRIMARY KEY(`id`)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE nutrition_macro_group (nutrition_meal_id INT DEFAULT NULL, recipe_id INT DEFAULT NULL, `id` INT AUTO_INCREMENT NOT NULL, `type` VARCHAR(255) NOT NULL COMMENT \'(DC2Type:nutrition_macro_group_type)\', `name` VARCHAR(255) NOT NULL, `order` INT NOT NULL, `note` VARCHAR(255) DEFAULT NULL, specialDish_id INT DEFAULT NULL, INDEX IDX_7185AC9A326784 (nutrition_meal_id), INDEX IDX_7185AC59D8A214 (recipe_id), INDEX IDX_7185AC2377217C (specialDish_id), PRIMARY KEY(`id`)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE nutrition_macro_group_detail (`id` INT AUTO_INCREMENT NOT NULL, `um_type` VARCHAR(255) DEFAULT NULL COMMENT \'(DC2Type:um_type)\', `value` INT DEFAULT NULL, `frequency_um_type` VARCHAR(255) DEFAULT NULL COMMENT \'(DC2Type:um_type)\', `frequency_value` INT DEFAULT NULL, `order` INT NOT NULL, `note` VARCHAR(255) DEFAULT NULL, `nutrition_macro_group_id` INT NOT NULL, `item_id` INT NOT NULL, INDEX IDX_DDF16D1E6244AFF2 (`nutrition_macro_group_id`), INDEX IDX_DDF16D1ECC39D717 (`item_id`), PRIMARY KEY(`id`)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE nutrition_meal (nutrition_program_id INT NOT NULL, `id` INT AUTO_INCREMENT NOT NULL, `order` INT NOT NULL, `name` VARCHAR(255) DEFAULT NULL, `note` VARCHAR(255) DEFAULT NULL, INDEX IDX_B5CC600F9920AB9D (nutrition_program_id), PRIMARY KEY(`id`)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE nutrition_program (`id` INT AUTO_INCREMENT NOT NULL, `membership_id` INT DEFAULT NULL, `des` VARCHAR(255) DEFAULT NULL, `start_date` DATE DEFAULT NULL, `end_date` DATE DEFAULT NULL, `start_text` VARCHAR(255) DEFAULT NULL, `end_text` VARCHAR(255) DEFAULT NULL, `category` VARCHAR(255) NOT NULL COMMENT \'(DC2Type:nutrition_category)\', `calorie` VARCHAR(255) NOT NULL COMMENT \'(DC2Type:nutrition_calorie)\', `creation_date` DATETIME NOT NULL, `modified_user` VARCHAR(50) DEFAULT NULL, `modified_date` DATETIME DEFAULT NULL, PRIMARY KEY(`id`)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE recipe (`id` INT AUTO_INCREMENT NOT NULL, `name` VARCHAR(255) DEFAULT NULL, `recipeType` VARCHAR(255) DEFAULT NULL COMMENT \'(DC2Type:recipeType)\', `difficultyPreparationLevel` VARCHAR(255) NOT NULL COMMENT \'(DC2Type:difficultyPreparationLevel)\', `preparation_time` INT DEFAULT NULL, `cooking_time` INT DEFAULT NULL, `preparation_des` LONGTEXT DEFAULT NULL, `creation_user` VARCHAR(50) NOT NULL, `creation_date` DATETIME NOT NULL, `modified_user` VARCHAR(50) DEFAULT NULL, `modified_date` DATETIME DEFAULT NULL, `image` LONGBLOB DEFAULT NULL, PRIMARY KEY(`id`)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE recipe_document (`id` INT AUTO_INCREMENT NOT NULL, `recipe_id` INT NOT NULL, `document_id` INT NOT NULL, INDEX IDX_AEF92FE85DEACDA8 (`recipe_id`), INDEX IDX_AEF92FE85D9C4E11 (`document_id`), PRIMARY KEY(`id`)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE recipe_ingredient (recipe_id INT NOT NULL, ingredient_id INT NOT NULL, `id` INT AUTO_INCREMENT NOT NULL, `um_type` VARCHAR(255) DEFAULT NULL COMMENT \'(DC2Type:um_type)\', `value` INT DEFAULT NULL, INDEX IDX_22D1FE1359D8A214 (recipe_id), INDEX IDX_22D1FE13933FE08C (ingredient_id), PRIMARY KEY(`id`)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE special_dish (`id` INT AUTO_INCREMENT NOT NULL, `name` VARCHAR(255) DEFAULT NULL, `note` VARCHAR(500) DEFAULT NULL, `frequency_um_type` VARCHAR(255) DEFAULT NULL COMMENT \'(DC2Type:um_type)\', `frequency_value` INT DEFAULT NULL, `creation_user` VARCHAR(50) NOT NULL, `creation_date` DATETIME NOT NULL, `modified_user` VARCHAR(50) DEFAULT NULL, `modified_date` DATETIME DEFAULT NULL, `image` LONGBLOB DEFAULT NULL, PRIMARY KEY(`id`)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE special_dish_document (`id` INT AUTO_INCREMENT NOT NULL, `specialDish_id` INT NOT NULL, `document_id` INT NOT NULL, INDEX IDX_B8917517C40901D6 (`specialDish_id`), INDEX IDX_B89175175D9C4E11 (`document_id`), PRIMARY KEY(`id`)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE special_dish_ingredient (special_dish_id INT NOT NULL, ingredient_id INT NOT NULL, `id` INT AUTO_INCREMENT NOT NULL, `um_type` VARCHAR(255) DEFAULT NULL COMMENT \'(DC2Type:um_type)\', `value` INT DEFAULT NULL, INDEX IDX_3A4BADE3CC82EC5E (special_dish_id), INDEX IDX_3A4BADE3933FE08C (ingredient_id), PRIMARY KEY(`id`)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
$this->addSql('ALTER TABLE ingredient_alternative ADD CONSTRAINT FK_B68C9363658FE3CE FOREIGN KEY (ingredient_a_id) REFERENCES ingredient (id)');
$this->addSql('ALTER TABLE ingredient_alternative ADD CONSTRAINT FK_B68C9363773A4C20 FOREIGN KEY (ingredient_b_id) REFERENCES ingredient (id)');
$this->addSql('ALTER TABLE ingredient_document ADD CONSTRAINT FK_AA6FDAF83F7B41FD FOREIGN KEY (`ingredient_id`) REFERENCES ingredient (`id`) ON DELETE CASCADE');
$this->addSql('ALTER TABLE ingredient_document ADD CONSTRAINT FK_AA6FDAF85D9C4E11 FOREIGN KEY (`document_id`) REFERENCES document (`id`) ON DELETE CASCADE');
$this->addSql('ALTER TABLE nutrition_macro_group ADD CONSTRAINT FK_7185AC9A326784 FOREIGN KEY (nutrition_meal_id) REFERENCES nutrition_meal (id)');
$this->addSql('ALTER TABLE nutrition_macro_group ADD CONSTRAINT FK_7185AC59D8A214 FOREIGN KEY (recipe_id) REFERENCES recipe (id)');
$this->addSql('ALTER TABLE nutrition_macro_group ADD CONSTRAINT FK_7185AC2377217C FOREIGN KEY (specialDish_id) REFERENCES special_dish (id)');
$this->addSql('ALTER TABLE nutrition_macro_group_detail ADD CONSTRAINT FK_DDF16D1E6244AFF2 FOREIGN KEY (`nutrition_macro_group_id`) REFERENCES nutrition_macro_group (`id`) ON DELETE CASCADE');
$this->addSql('ALTER TABLE nutrition_macro_group_detail ADD CONSTRAINT FK_DDF16D1ECC39D717 FOREIGN KEY (`item_id`) REFERENCES item (`id`) ON DELETE CASCADE');
$this->addSql('ALTER TABLE nutrition_meal ADD CONSTRAINT FK_B5CC600F9920AB9D FOREIGN KEY (nutrition_program_id) REFERENCES nutrition_program (id)');
$this->addSql('ALTER TABLE recipe_document ADD CONSTRAINT FK_AEF92FE85DEACDA8 FOREIGN KEY (`recipe_id`) REFERENCES recipe (`id`) ON DELETE CASCADE');
$this->addSql('ALTER TABLE recipe_document ADD CONSTRAINT FK_AEF92FE85D9C4E11 FOREIGN KEY (`document_id`) REFERENCES document (`id`) ON DELETE CASCADE');
$this->addSql('ALTER TABLE recipe_ingredient ADD CONSTRAINT FK_22D1FE1359D8A214 FOREIGN KEY (recipe_id) REFERENCES recipe (id)');
$this->addSql('ALTER TABLE recipe_ingredient ADD CONSTRAINT FK_22D1FE13933FE08C FOREIGN KEY (ingredient_id) REFERENCES ingredient (id)');
$this->addSql('ALTER TABLE special_dish_document ADD CONSTRAINT FK_B8917517C40901D6 FOREIGN KEY (`specialDish_id`) REFERENCES special_dish (`id`) ON DELETE CASCADE');
$this->addSql('ALTER TABLE special_dish_document ADD CONSTRAINT FK_B89175175D9C4E11 FOREIGN KEY (`document_id`) REFERENCES document (`id`) ON DELETE CASCADE');
$this->addSql('ALTER TABLE special_dish_ingredient ADD CONSTRAINT FK_3A4BADE3CC82EC5E FOREIGN KEY (special_dish_id) REFERENCES special_dish (id)');
$this->addSql('ALTER TABLE special_dish_ingredient ADD CONSTRAINT FK_3A4BADE3933FE08C FOREIGN KEY (ingredient_id) REFERENCES ingredient (id)');
$this->addSql('ALTER TABLE item ADD `description` VARCHAR(4000) DEFAULT NULL, ADD `thumbnail` LONGBLOB DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('ALTER TABLE ingredient_alternative DROP FOREIGN KEY FK_B68C9363658FE3CE');
$this->addSql('ALTER TABLE ingredient_alternative DROP FOREIGN KEY FK_B68C9363773A4C20');
$this->addSql('ALTER TABLE ingredient_document DROP FOREIGN KEY FK_AA6FDAF83F7B41FD');
$this->addSql('ALTER TABLE recipe_ingredient DROP FOREIGN KEY FK_22D1FE13933FE08C');
$this->addSql('ALTER TABLE special_dish_ingredient DROP FOREIGN KEY FK_3A4BADE3933FE08C');
$this->addSql('ALTER TABLE nutrition_macro_group_detail DROP FOREIGN KEY FK_DDF16D1E6244AFF2');
$this->addSql('ALTER TABLE nutrition_macro_group DROP FOREIGN KEY FK_7185AC9A326784');
$this->addSql('ALTER TABLE nutrition_meal DROP FOREIGN KEY FK_B5CC600F9920AB9D');
$this->addSql('ALTER TABLE nutrition_macro_group DROP FOREIGN KEY FK_7185AC59D8A214');
$this->addSql('ALTER TABLE recipe_document DROP FOREIGN KEY FK_AEF92FE85DEACDA8');
$this->addSql('ALTER TABLE recipe_ingredient DROP FOREIGN KEY FK_22D1FE1359D8A214');
$this->addSql('ALTER TABLE nutrition_macro_group DROP FOREIGN KEY FK_7185AC2377217C');
$this->addSql('ALTER TABLE special_dish_document DROP FOREIGN KEY FK_B8917517C40901D6');
$this->addSql('ALTER TABLE special_dish_ingredient DROP FOREIGN KEY FK_3A4BADE3CC82EC5E');
$this->addSql('DROP TABLE ingredient');
$this->addSql('DROP TABLE ingredient_alternative');
$this->addSql('DROP TABLE ingredient_document');
$this->addSql('DROP TABLE nutrition_macro_group');
$this->addSql('DROP TABLE nutrition_macro_group_detail');
$this->addSql('DROP TABLE nutrition_meal');
$this->addSql('DROP TABLE nutrition_program');
$this->addSql('DROP TABLE recipe');
$this->addSql('DROP TABLE recipe_document');
$this->addSql('DROP TABLE recipe_ingredient');
$this->addSql('DROP TABLE special_dish');
$this->addSql('DROP TABLE special_dish_document');
$this->addSql('DROP TABLE special_dish_ingredient');
$this->addSql('ALTER TABLE item DROP `description`, DROP `thumbnail`');
}
}