<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use App\Entity\DocumentTemplate;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20190809074612 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('ALTER TABLE ad_restaurant DROP FOREIGN KEY FK_141C4185BF396750');
$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');
$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');
$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');
$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');
$this->addSql('ALTER TABLE resource_document_template ADD CONSTRAINT FK_8A8C208689329D25 FOREIGN KEY (resource_id) REFERENCES resource (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE resource_document_template ADD CONSTRAINT FK_8A8C2086877338D2 FOREIGN KEY (document_template_id) REFERENCES document_template (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE booking_document ADD CONSTRAINT FK_E35D14FB3301C60 FOREIGN KEY (booking_id) REFERENCES booking (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE booking_document ADD CONSTRAINT FK_E35D14FBC33F7837 FOREIGN KEY (document_id) REFERENCES document (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE document ADD CONSTRAINT FK_D8698A765DA0FB8 FOREIGN KEY (template_id) REFERENCES document_template (id)');
$this->addSql('DROP TABLE ad_base');
$this->addSql('DROP TABLE ad_restaurant');
$this->addSql('ALTER TABLE resource DROP FOREIGN KEY FK_BC91F4165DA0FB8');
$this->addSql('DROP INDEX IDX_BC91F4165DA0FB8 ON resource');
$this->addSql('ALTER TABLE resource DROP template_id');
$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\"}]')");
}
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 booking_document DROP FOREIGN KEY FK_E35D14FBC33F7837');
$this->addSql('ALTER TABLE resource_document_template DROP FOREIGN KEY FK_8A8C2086877338D2');
$this->addSql('ALTER TABLE document DROP FOREIGN KEY FK_D8698A765DA0FB8');
$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 = \'\' ');
$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 = \'\' ');
$this->addSql('ALTER TABLE ad_base ADD CONSTRAINT FK_787BAC043301C60 FOREIGN KEY (booking_id) REFERENCES booking (id)');
$this->addSql('ALTER TABLE ad_restaurant ADD CONSTRAINT FK_141C4185BF396750 FOREIGN KEY (id) REFERENCES ad_base (id) ON DELETE CASCADE');
$this->addSql('DROP TABLE resource_document_template');
$this->addSql('DROP TABLE booking_document');
$this->addSql('DROP TABLE document');
$this->addSql('DROP TABLE document_template');
$this->addSql('ALTER TABLE resource ADD template_id INT NOT NULL');
$this->addSql('ALTER TABLE resource ADD CONSTRAINT FK_BC91F4165DA0FB8 FOREIGN KEY (template_id) REFERENCES resource_template (id)');
$this->addSql('CREATE INDEX IDX_BC91F4165DA0FB8 ON resource (template_id)');
}
}