migrations/Version20190809074612.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use App\Entity\DocumentTemplate;
  5. use Doctrine\DBAL\Schema\Schema;
  6. use Doctrine\Migrations\AbstractMigration;
  7. /**
  8.  * Auto-generated Migration: Please modify to your needs!
  9.  */
  10. final class Version20190809074612 extends AbstractMigration
  11. {
  12.     public function getDescription() : string
  13.     {
  14.         return '';
  15.     }
  16.     public function up(Schema $schema) : void
  17.     {
  18.         // this up() migration is auto-generated, please modify it to your needs
  19.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql''Migration can only be executed safely on \'mysql\'.');
  20.         $this->addSql('ALTER TABLE ad_restaurant DROP FOREIGN KEY FK_141C4185BF396750');
  21.         $this->addSql('CREATE TABLE resource_document_template (resource_id INT NOT NULL, document_template_id INT NOT NULL, INDEX IDX_8A8C208689329D25 (resource_id), INDEX IDX_8A8C2086877338D2 (document_template_id), PRIMARY KEY(resource_id, document_template_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
  22.         $this->addSql('CREATE TABLE booking_document (booking_id INT NOT NULL, document_id INT NOT NULL, INDEX IDX_E35D14FB3301C60 (booking_id), INDEX IDX_E35D14FBC33F7837 (document_id), PRIMARY KEY(booking_id, document_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
  23.         $this->addSql('CREATE TABLE document (id INT AUTO_INCREMENT NOT NULL, template_id INT NOT NULL, data LONGTEXT NOT NULL COMMENT \'(DC2Type:json_array)\', INDEX IDX_D8698A765DA0FB8 (template_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
  24.         $this->addSql('CREATE TABLE document_template (id INT AUTO_INCREMENT NOT NULL, buildin_type INT NOT NULL, data_structure LONGTEXT NOT NULL COMMENT \'(DC2Type:json_array)\', name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
  25.         $this->addSql('ALTER TABLE resource_document_template ADD CONSTRAINT FK_8A8C208689329D25 FOREIGN KEY (resource_id) REFERENCES resource (id) ON DELETE CASCADE');
  26.         $this->addSql('ALTER TABLE resource_document_template ADD CONSTRAINT FK_8A8C2086877338D2 FOREIGN KEY (document_template_id) REFERENCES document_template (id) ON DELETE CASCADE');
  27.         $this->addSql('ALTER TABLE booking_document ADD CONSTRAINT FK_E35D14FB3301C60 FOREIGN KEY (booking_id) REFERENCES booking (id) ON DELETE CASCADE');
  28.         $this->addSql('ALTER TABLE booking_document ADD CONSTRAINT FK_E35D14FBC33F7837 FOREIGN KEY (document_id) REFERENCES document (id) ON DELETE CASCADE');
  29.         $this->addSql('ALTER TABLE document ADD CONSTRAINT FK_D8698A765DA0FB8 FOREIGN KEY (template_id) REFERENCES document_template (id)');
  30.         $this->addSql('DROP TABLE ad_base');
  31.         $this->addSql('DROP TABLE ad_restaurant');
  32.         $this->addSql('ALTER TABLE resource DROP FOREIGN KEY FK_BC91F4165DA0FB8');
  33.         $this->addSql('DROP INDEX IDX_BC91F4165DA0FB8 ON resource');
  34.         $this->addSql('ALTER TABLE resource DROP template_id');
  35.         $this->addSql('INSERT INTO document_template (id, name, buildin_type, data_structure) VALUES (1000, "Financial Control", '.DocumentTemplate::FINANCIAL_CONTROL.", '[{\"name\":\"financialDepositPaid\",\"label\":\"Deposit Paid\",\"type\":\"bool\",\"default\":false},{\"name\":\"financialFoodPreorder\",\"label\":\"Food Preorder\",\"type\":\"bool\",\"default\":false},{\"name\":\"financialFinalAmountPaid\",\"label\":\"Final Amount Paid\",\"type\":\"bool\",\"default\":false},{\"name\":\"financialCardType\",\"label\":\"Card Type\",\"type\":\"list\",\"options\":[\"Master Card\",\"Visa\",\"Amex\"]},{\"name\":\"financialDepositDate\",\"label\":\"Date deposit taken\",\"type\":\"date\"},{\"name\":\"financialDeposit\",\"label\":\"Deposit Amount\",\"type\":\"money\"},{\"name\":\"financialDepositFinal\",\"label\":\"Final amount paid\",\"type\":\"money\"},{\"name\":\"financialMinSpend\",\"label\":\"Min. spend\",\"type\":\"money\"}]')");
  36.     }
  37.     public function down(Schema $schema) : void
  38.     {
  39.         // this down() migration is auto-generated, please modify it to your needs
  40.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql''Migration can only be executed safely on \'mysql\'.');
  41.         $this->addSql('ALTER TABLE booking_document DROP FOREIGN KEY FK_E35D14FBC33F7837');
  42.         $this->addSql('ALTER TABLE resource_document_template DROP FOREIGN KEY FK_8A8C2086877338D2');
  43.         $this->addSql('ALTER TABLE document DROP FOREIGN KEY FK_D8698A765DA0FB8');
  44.         $this->addSql('CREATE TABLE ad_base (id INT AUTO_INCREMENT NOT NULL, booking_id INT NOT NULL, template VARCHAR(255) NOT NULL COLLATE utf8mb4_unicode_ci, UNIQUE INDEX UNIQ_787BAC043301C60 (booking_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB COMMENT = \'\' ');
  45.         $this->addSql('CREATE TABLE ad_restaurant (id INT NOT NULL, alert LONGTEXT DEFAULT NULL COLLATE utf8mb4_unicode_ci, allergies LONGTEXT DEFAULT NULL COLLATE utf8mb4_unicode_ci, additional_notes LONGTEXT DEFAULT NULL COLLATE utf8mb4_unicode_ci, no_adults VARCHAR(64) DEFAULT NULL COLLATE utf8mb4_unicode_ci, no_u18 VARCHAR(64) DEFAULT NULL COLLATE utf8mb4_unicode_ci, no_babies VARCHAR(64) DEFAULT NULL COLLATE utf8mb4_unicode_ci, total_guests VARCHAR(64) DEFAULT NULL COLLATE utf8mb4_unicode_ci, canapes_notes LONGTEXT DEFAULT NULL COLLATE utf8mb4_unicode_ci, canapes_menu LONGTEXT DEFAULT NULL COLLATE utf8mb4_unicode_ci, arrival_drinks LONGTEXT DEFAULT NULL COLLATE utf8mb4_unicode_ci, arrival_drinks_location VARCHAR(255) DEFAULT NULL COLLATE utf8mb4_unicode_ci, bar_terms VARCHAR(255) DEFAULT NULL COLLATE utf8mb4_unicode_ci, meal_drinks LONGTEXT DEFAULT NULL COLLATE utf8mb4_unicode_ci, toast_wine VARCHAR(255) DEFAULT NULL COLLATE utf8mb4_unicode_ci, cut_cake VARCHAR(255) DEFAULT NULL COLLATE utf8mb4_unicode_ci, meal_time VARCHAR(64) DEFAULT NULL COLLATE utf8mb4_unicode_ci, meal_menu LONGTEXT DEFAULT NULL COLLATE utf8mb4_unicode_ci, meal_menu_u12 LONGTEXT DEFAULT NULL COLLATE utf8mb4_unicode_ci, meal_menu_special LONGTEXT DEFAULT NULL COLLATE utf8mb4_unicode_ci, room_layout LONGTEXT DEFAULT NULL COLLATE utf8mb4_unicode_ci, room_high_chairs VARCHAR(64) DEFAULT NULL COLLATE utf8mb4_unicode_ci, our_menus VARCHAR(255) DEFAULT NULL COLLATE utf8mb4_unicode_ci, napkins VARCHAR(255) DEFAULT NULL COLLATE utf8mb4_unicode_ci, cloths VARCHAR(255) DEFAULT NULL COLLATE utf8mb4_unicode_ci, flowers_delivery VARCHAR(255) DEFAULT NULL COLLATE utf8mb4_unicode_ci, florist VARCHAR(255) DEFAULT NULL COLLATE utf8mb4_unicode_ci, florist_contact VARCHAR(255) DEFAULT NULL COLLATE utf8mb4_unicode_ci, cake VARCHAR(255) DEFAULT NULL COLLATE utf8mb4_unicode_ci, guest_book VARCHAR(255) DEFAULT NULL COLLATE utf8mb4_unicode_ci, music_photo LONGTEXT DEFAULT NULL COLLATE utf8mb4_unicode_ci, venue_dressing LONGTEXT DEFAULT NULL COLLATE utf8mb4_unicode_ci, venue_lighting LONGTEXT DEFAULT NULL COLLATE utf8mb4_unicode_ci, table_extras LONGTEXT DEFAULT NULL COLLATE utf8mb4_unicode_ci, 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 utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB COMMENT = \'\' ');
  46.         $this->addSql('ALTER TABLE ad_base ADD CONSTRAINT FK_787BAC043301C60 FOREIGN KEY (booking_id) REFERENCES booking (id)');
  47.         $this->addSql('ALTER TABLE ad_restaurant ADD CONSTRAINT FK_141C4185BF396750 FOREIGN KEY (id) REFERENCES ad_base (id) ON DELETE CASCADE');
  48.         $this->addSql('DROP TABLE resource_document_template');
  49.         $this->addSql('DROP TABLE booking_document');
  50.         $this->addSql('DROP TABLE document');
  51.         $this->addSql('DROP TABLE document_template');
  52.         $this->addSql('ALTER TABLE resource ADD template_id INT NOT NULL');
  53.         $this->addSql('ALTER TABLE resource ADD CONSTRAINT FK_BC91F4165DA0FB8 FOREIGN KEY (template_id) REFERENCES resource_template (id)');
  54.         $this->addSql('CREATE INDEX IDX_BC91F4165DA0FB8 ON resource (template_id)');
  55.     }
  56. }