migrations/Version20180910214446.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 Version20180910214446 extends AbstractMigration
  10. {
  11.     public function up(Schema $schema): void
  12.     {
  13.         // this up() migration is auto-generated, please modify it to your needs
  14.         $this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
  15.         $this->addSql('
  16.             CREATE TABLE filter (
  17.                 id INT AUTO_INCREMENT NOT NULL,
  18.                 user_id INT DEFAULT NULL,
  19.                 name VARCHAR(255) NOT NULL,
  20.                 section ENUM(\'section_lead\') NOT NULL COMMENT \'(DC2Type:SectionType)\',
  21.                 params LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:array)\',
  22.                 created_at DATETIME NOT NULL,
  23.                 modified_at DATETIME NOT NULL,
  24.                 INDEX IDX_7FC45F1DA76ED395 (user_id),
  25.                 PRIMARY KEY(id)
  26.             ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB
  27.         ');
  28.         $this->addSql('ALTER TABLE filter ADD CONSTRAINT FK_7FC45F1DA76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE');
  29.     }
  30.     public function down(Schema $schema): void
  31.     {
  32.         // this down() migration is auto-generated, please modify it to your needs
  33.         $this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
  34.         $this->addSql('DROP TABLE filter');
  35.     }
  36. }