migrations/Version20190612101148.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 Version20190612101148 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->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql''Migration can only be executed safely on \'mysql\'.');
  19.         $this->addSql('CREATE TABLE ad_base (id INT AUTO_INCREMENT NOT NULL, booking_id INT NOT NULL, template VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_787BAC043301C60 (booking_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
  20.         $this->addSql('CREATE TABLE ad_restaurant (id INT NOT NULL, alert VARCHAR(255) NOT NULL, allergies VARCHAR(255) NOT NULL, additional_notes VARCHAR(255) NOT NULL, no_adults VARCHAR(64) NOT NULL, no_u18 VARCHAR(64) NOT NULL, no_babies VARCHAR(64) NOT NULL, total_guests VARCHAR(64) NOT NULL, canapes_notes LONGTEXT NOT NULL, canapes_menu LONGTEXT NOT NULL, arrival_drinks LONGTEXT NOT NULL, arrival_drinks_location VARCHAR(255) NOT NULL, bar_terms VARCHAR(255) NOT NULL, meal_drinks LONGTEXT NOT NULL, toast_wine VARCHAR(255) NOT NULL, cut_cake VARCHAR(255) NOT NULL, meal_time VARCHAR(64) NOT NULL, meal_menu LONGTEXT NOT NULL, meal_menu_u12 LONGTEXT NOT NULL, meal_menu_special LONGTEXT NOT NULL, room_layout LONGTEXT NOT NULL, room_high_chairs VARCHAR(64) NOT NULL, our_menus VARCHAR(255) NOT NULL, napkins VARCHAR(255) NOT NULL, cloths VARCHAR(255) NOT NULL, flowers_delivery VARCHAR(255) NOT NULL, florist VARCHAR(255) NOT NULL, florist_contact VARCHAR(255) NOT NULL, cake VARCHAR(255) NOT NULL, guest_book VARCHAR(255) NOT NULL, music_photo LONGTEXT NOT NULL, venue_dressing LONGTEXT NOT NULL, venue_lighting LONGTEXT NOT NULL, table_extras LONGTEXT NOT NULL, financial_deposit_paid TINYINT(1) NOT NULL, financial_food_preorder TINYINT(1) NOT NULL, financial_final_amount_paid TINYINT(1) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
  21.         $this->addSql('CREATE TABLE resource_template (id INT AUTO_INCREMENT NOT NULL, buildin_type INT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
  22.         $this->addSql('ALTER TABLE resource ADD template_id INT NOT NULL');
  23.         $this->addSql('INSERT INTO resource_template (id, name, buildin_type) VALUES (1, "None", 1 )');
  24.         $this->addSql('INSERT INTO resource_template (id, name, buildin_type) VALUES (2, "Restaurant Event", 3 )');
  25.         $this->addSql('UPDATE resource SET template_id = 2');
  26.         $this->addSql("INSERT INTO ad_base 
  27.                             SELECT booking.id as id, booking.id as booking_id, 'event' as template 
  28.                             FROM   booking
  29.                      ");
  30.         $this->addSql("INSERT INTO ad_restaurant 
  31.                             SELECT booking.id as id, '' as alert, '' as allergies, '' as additional_notes, '' as no_adults, '' as no_u18, '' as no_babies, '' as total_guests, '' as canapes_notes, '' as canapes_menu, '' as arrival_drinks, '' as arrival_drinks_location, '' as bar_terms, '' as meal_drinks, '' as toast_wine, '' as cut_cake, '' as meal_time, '' as meal_menu, '' as meal_menu_u12, '' as meal_menu_special, '' as room_layout, '' as room_high_chairs, '' as our_menus, '' as napkins, '' as cloths, '' as flowers_delivery, '' as florist, '' as florist_contact, '' as cake, '' as guest_book, '' as music_photo, '' as venue_dressing, '' as venue_lighting, '' as table_extras, 0 as financial_deposit_paid, 0 as financial_food_preorder, 0 as financial_final_amount_paid
  32.                             FROM   booking
  33.                      ");
  34.         $this->addSql('ALTER TABLE ad_base ADD CONSTRAINT FK_787BAC043301C60 FOREIGN KEY (booking_id) REFERENCES booking (id)');
  35.         $this->addSql('ALTER TABLE ad_restaurant ADD CONSTRAINT FK_141C4185BF396750 FOREIGN KEY (id) REFERENCES ad_base (id) ON DELETE CASCADE');
  36.         $this->addSql('ALTER TABLE resource ADD CONSTRAINT FK_BC91F4165DA0FB8 FOREIGN KEY (template_id) REFERENCES resource_template (id)');
  37.         $this->addSql('CREATE INDEX IDX_BC91F4165DA0FB8 ON resource (template_id)');
  38.     }
  39.     public function down(Schema $schema) : void
  40.     {
  41.         // this down() migration is auto-generated, please modify it to your needs
  42.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql''Migration can only be executed safely on \'mysql\'.');
  43.         $this->addSql('ALTER TABLE ad_restaurant DROP FOREIGN KEY FK_141C4185BF396750');
  44.         $this->addSql('ALTER TABLE resource DROP FOREIGN KEY FK_BC91F4165DA0FB8');
  45.         $this->addSql('DROP TABLE ad_base');
  46.         $this->addSql('DROP TABLE ad_restaurant');
  47.         $this->addSql('DROP TABLE resource_template');
  48.         $this->addSql('DROP INDEX IDX_BC91F4165DA0FB8 ON resource');
  49.         $this->addSql('ALTER TABLE resource DROP template_id');
  50.     }
  51. }