<?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 Version20190612101148 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 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');
$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');
$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');
$this->addSql('ALTER TABLE resource ADD template_id INT NOT NULL');
$this->addSql('INSERT INTO resource_template (id, name, buildin_type) VALUES (1, "None", 1 )');
$this->addSql('INSERT INTO resource_template (id, name, buildin_type) VALUES (2, "Restaurant Event", 3 )');
$this->addSql('UPDATE resource SET template_id = 2');
$this->addSql("INSERT INTO ad_base
SELECT booking.id as id, booking.id as booking_id, 'event' as template
FROM booking
");
$this->addSql("INSERT INTO ad_restaurant
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
FROM booking
");
$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('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)');
}
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 ad_restaurant DROP FOREIGN KEY FK_141C4185BF396750');
$this->addSql('ALTER TABLE resource DROP FOREIGN KEY FK_BC91F4165DA0FB8');
$this->addSql('DROP TABLE ad_base');
$this->addSql('DROP TABLE ad_restaurant');
$this->addSql('DROP TABLE resource_template');
$this->addSql('DROP INDEX IDX_BC91F4165DA0FB8 ON resource');
$this->addSql('ALTER TABLE resource DROP template_id');
}
}