migrations/Version20200114172623.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 Version20200114172623 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('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
  19.         $this->addSql('CREATE TABLE config_stage_item_join_config_stage_category (item_id INT NOT NULL, category_id INT NOT NULL, INDEX IDX_A18CADFD126F525E (item_id), INDEX IDX_A18CADFD12469DE2 (category_id), PRIMARY KEY(item_id, category_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
  20.         $this->addSql('CREATE TABLE config_stage_category (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, INDEX idx_name (name), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
  21.         $this->addSql('ALTER TABLE config_stage_item_join_config_stage_category ADD CONSTRAINT FK_A18CADFD126F525E FOREIGN KEY (item_id) REFERENCES config_stage_item (id) ON DELETE CASCADE');
  22.         $this->addSql('ALTER TABLE config_stage_item_join_config_stage_category ADD CONSTRAINT FK_A18CADFD12469DE2 FOREIGN KEY (category_id) REFERENCES config_stage_category (id) ON DELETE CASCADE');
  23.     }
  24.     public function down(Schema $schema): void
  25.     {
  26.         // this down() migration is auto-generated, please modify it to your needs
  27.         $this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
  28.         $this->addSql('ALTER TABLE config_stage_item_join_config_stage_category DROP FOREIGN KEY FK_A18CADFD12469DE2');
  29.         $this->addSql('DROP TABLE config_stage_item_join_config_stage_category');
  30.         $this->addSql('DROP TABLE config_stage_category');
  31.     }
  32. }