<?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 Version20190605134317 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 action (id INT AUTO_INCREMENT NOT NULL, booking_id INT NOT NULL, created_by INT DEFAULT NULL, updated_by INT DEFAULT NULL, type VARCHAR(255) NOT NULL COMMENT \'(DC2Type:setting_type_enum)\', notes LONGTEXT NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX IDX_47CC8C923301C60 (booking_id), INDEX IDX_47CC8C92DE12AB56 (created_by), INDEX IDX_47CC8C9216FE72E1 (updated_by), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE booking (id INT AUTO_INCREMENT NOT NULL, customer_id INT NOT NULL, resource_id INT NOT NULL, user_id INT DEFAULT NULL, created_by INT DEFAULT NULL, updated_by INT DEFAULT NULL, start DATETIME NOT NULL, end DATETIME DEFAULT NULL, all_day TINYINT(1) NOT NULL, allocation_amount INT NOT NULL, state VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX IDX_E00CEDDE9395C3F3 (customer_id), INDEX IDX_E00CEDDE89329D25 (resource_id), INDEX IDX_E00CEDDEA76ED395 (user_id), INDEX IDX_E00CEDDEDE12AB56 (created_by), INDEX IDX_E00CEDDE16FE72E1 (updated_by), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE customer (id INT AUTO_INCREMENT NOT NULL, created_by INT DEFAULT NULL, updated_by INT DEFAULT NULL, email VARCHAR(255) DEFAULT NULL, first_name VARCHAR(255) DEFAULT NULL, last_name VARCHAR(255) DEFAULT NULL, telephone VARCHAR(255) DEFAULT NULL, memo LONGTEXT DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX IDX_81398E09DE12AB56 (created_by), INDEX IDX_81398E0916FE72E1 (updated_by), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE resource (id INT AUTO_INCREMENT NOT NULL, organization_unit_id INT DEFAULT NULL, created_by INT DEFAULT NULL, updated_by INT DEFAULT NULL, amount INT NOT NULL, before_time VARCHAR(255) DEFAULT NULL COMMENT \'(DC2Type:dateinterval)\', after_time VARCHAR(255) DEFAULT NULL COMMENT \'(DC2Type:dateinterval)\', created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, name VARCHAR(255) NOT NULL, INDEX IDX_BC91F416356FF84E (organization_unit_id), INDEX IDX_BC91F416DE12AB56 (created_by), INDEX IDX_BC91F41616FE72E1 (updated_by), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
$this->addSql('ALTER TABLE action ADD CONSTRAINT FK_47CC8C923301C60 FOREIGN KEY (booking_id) REFERENCES booking (id)');
$this->addSql('ALTER TABLE action ADD CONSTRAINT FK_47CC8C92DE12AB56 FOREIGN KEY (created_by) REFERENCES fos_user (id)');
$this->addSql('ALTER TABLE action ADD CONSTRAINT FK_47CC8C9216FE72E1 FOREIGN KEY (updated_by) REFERENCES fos_user (id)');
$this->addSql('ALTER TABLE booking ADD CONSTRAINT FK_E00CEDDE9395C3F3 FOREIGN KEY (customer_id) REFERENCES customer (id)');
$this->addSql('ALTER TABLE booking ADD CONSTRAINT FK_E00CEDDE89329D25 FOREIGN KEY (resource_id) REFERENCES resource (id)');
$this->addSql('ALTER TABLE booking ADD CONSTRAINT FK_E00CEDDEA76ED395 FOREIGN KEY (user_id) REFERENCES fos_user (id)');
$this->addSql('ALTER TABLE booking ADD CONSTRAINT FK_E00CEDDEDE12AB56 FOREIGN KEY (created_by) REFERENCES fos_user (id)');
$this->addSql('ALTER TABLE booking ADD CONSTRAINT FK_E00CEDDE16FE72E1 FOREIGN KEY (updated_by) REFERENCES fos_user (id)');
$this->addSql('ALTER TABLE customer ADD CONSTRAINT FK_81398E09DE12AB56 FOREIGN KEY (created_by) REFERENCES fos_user (id)');
$this->addSql('ALTER TABLE customer ADD CONSTRAINT FK_81398E0916FE72E1 FOREIGN KEY (updated_by) REFERENCES fos_user (id)');
$this->addSql('ALTER TABLE resource ADD CONSTRAINT FK_BC91F416356FF84E FOREIGN KEY (organization_unit_id) REFERENCES organization_unit (id)');
$this->addSql('ALTER TABLE resource ADD CONSTRAINT FK_BC91F416DE12AB56 FOREIGN KEY (created_by) REFERENCES fos_user (id)');
$this->addSql('ALTER TABLE resource ADD CONSTRAINT FK_BC91F41616FE72E1 FOREIGN KEY (updated_by) REFERENCES fos_user (id)');
$this->addSql('DROP INDEX log_version_lookup_idx ON ext_log_entries');
$this->addSql('DROP INDEX log_class_lookup_idx ON ext_log_entries');
$this->addSql('DROP INDEX log_user_lookup_idx ON ext_log_entries');
$this->addSql('CREATE INDEX log_version_lookup_idx ON ext_log_entries (object_id, object_class, version)');
$this->addSql('CREATE INDEX log_class_lookup_idx ON ext_log_entries (object_class)');
$this->addSql('CREATE INDEX log_user_lookup_idx ON ext_log_entries (username)');
}
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 action DROP FOREIGN KEY FK_47CC8C923301C60');
$this->addSql('ALTER TABLE booking DROP FOREIGN KEY FK_E00CEDDE9395C3F3');
$this->addSql('ALTER TABLE booking DROP FOREIGN KEY FK_E00CEDDE89329D25');
$this->addSql('DROP TABLE action');
$this->addSql('DROP TABLE booking');
$this->addSql('DROP TABLE customer');
$this->addSql('DROP TABLE resource');
$this->addSql('DROP INDEX log_class_lookup_idx ON ext_log_entries');
$this->addSql('DROP INDEX log_user_lookup_idx ON ext_log_entries');
$this->addSql('DROP INDEX log_version_lookup_idx ON ext_log_entries');
$this->addSql('CREATE INDEX log_class_lookup_idx ON ext_log_entries (object_class(191))');
$this->addSql('CREATE INDEX log_user_lookup_idx ON ext_log_entries (username(191))');
$this->addSql('CREATE INDEX log_version_lookup_idx ON ext_log_entries (object_id, object_class(191), version)');
}
}