migrations/Version20190715194743.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 Version20190715194743 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 event (id INT AUTO_INCREMENT NOT NULL, organization_unit_id INT NOT NULL, event_type_id INT NOT NULL, status SMALLINT NOT NULL, date DATETIME NOT NULL, timetable LONGTEXT DEFAULT NULL, availability INT NOT NULL, code VARCHAR(32) NOT NULL, include_in_website_search TINYINT(1) NOT NULL, enrolment_details LONGTEXT DEFAULT NULL, duration_details LONGTEXT DEFAULT NULL, contact_name VARCHAR(255) DEFAULT NULL, contact_email VARCHAR(255) DEFAULT NULL, contact_phone VARCHAR(255) DEFAULT NULL, price NUMERIC(8, 2) NOT NULL, fee NUMERIC(8, 2) NOT NULL, event_notes LONGTEXT DEFAULT NULL, name VARCHAR(255) NOT NULL, INDEX IDX_3BAE0AA7356FF84E (organization_unit_id), INDEX IDX_3BAE0AA7401B253C (event_type_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
  20.         $this->addSql('ALTER TABLE event ADD CONSTRAINT FK_3BAE0AA7356FF84E FOREIGN KEY (organization_unit_id) REFERENCES organization_unit (id)');
  21.         $this->addSql('ALTER TABLE event ADD CONSTRAINT FK_3BAE0AA7401B253C FOREIGN KEY (event_type_id) REFERENCES event_type (id)');
  22.         $this->addSql('ALTER TABLE event_type DROP FOREIGN KEY FK_93151B8216FE72E1');
  23.         $this->addSql('ALTER TABLE event_type DROP FOREIGN KEY FK_93151B82DE12AB56');
  24.         $this->addSql('DROP INDEX IDX_93151B8216FE72E1 ON event_type');
  25.         $this->addSql('DROP INDEX IDX_93151B82DE12AB56 ON event_type');
  26.         $this->addSql('ALTER TABLE event_type DROP created_by, DROP updated_by, DROP created_at, DROP updated_at, CHANGE enrolment_details enrolment_details LONGTEXT DEFAULT NULL, CHANGE duration_details duration_details LONGTEXT DEFAULT NULL, CHANGE contact_name contact_name VARCHAR(255) DEFAULT NULL, CHANGE contact_email contact_email VARCHAR(255) DEFAULT NULL, CHANGE contact_phone contact_phone VARCHAR(255) DEFAULT NULL');
  27.     }
  28.     public function down(Schema $schema) : void
  29.     {
  30.         // this down() migration is auto-generated, please modify it to your needs
  31.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql''Migration can only be executed safely on \'mysql\'.');
  32.         $this->addSql('DROP TABLE event');
  33.         $this->addSql('ALTER TABLE event_type ADD created_by INT DEFAULT NULL, ADD updated_by INT DEFAULT NULL, ADD created_at DATETIME NOT NULL, ADD updated_at DATETIME NOT NULL, CHANGE enrolment_details enrolment_details LONGTEXT NOT NULL COLLATE utf8mb4_unicode_ci, CHANGE duration_details duration_details LONGTEXT NOT NULL COLLATE utf8mb4_unicode_ci, CHANGE contact_name contact_name VARCHAR(255) NOT NULL COLLATE utf8mb4_unicode_ci, CHANGE contact_email contact_email VARCHAR(255) NOT NULL COLLATE utf8mb4_unicode_ci, CHANGE contact_phone contact_phone VARCHAR(255) NOT NULL COLLATE utf8mb4_unicode_ci');
  34.         $this->addSql('ALTER TABLE event_type ADD CONSTRAINT FK_93151B8216FE72E1 FOREIGN KEY (updated_by) REFERENCES fos_user (id)');
  35.         $this->addSql('ALTER TABLE event_type ADD CONSTRAINT FK_93151B82DE12AB56 FOREIGN KEY (created_by) REFERENCES fos_user (id)');
  36.         $this->addSql('CREATE INDEX IDX_93151B8216FE72E1 ON event_type (updated_by)');
  37.         $this->addSql('CREATE INDEX IDX_93151B82DE12AB56 ON event_type (created_by)');
  38.     }
  39. }