migrations/Version20190515132626.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 Version20190515132626 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('ALTER TABLE std_content_types_attributes DROP FOREIGN KEY FK_9CBB7EA741BCBAEC');
  20.         $this->addSql('ALTER TABLE std_content_types_attributes DROP FOREIGN KEY FK_9CBB7EA7B6E62EFA');
  21.         $this->addSql('DROP INDEX IDX_9CBB7EA741BCBAEC ON std_content_types_attributes');
  22.         $this->addSql('DROP INDEX IDX_9CBB7EA7B6E62EFA ON std_content_types_attributes');
  23.         $this->addSql('ALTER TABLE std_content_types_attributes DROP PRIMARY KEY');
  24.         $this->addSql('ALTER TABLE std_content_types_attributes ADD content_type_machine_name VARCHAR(50) NOT NULL COMMENT \'Content type machine name\', ADD attribute_machine_name VARCHAR(50) NOT NULL COMMENT \'Attribute machine name\', DROP content_type, DROP attribute_id');
  25.         $this->addSql('ALTER TABLE std_content_types_attributes ADD PRIMARY KEY (content_type_machine_name, attribute_machine_name)');
  26.     }
  27.     public function down(Schema $schema) : void
  28.     {
  29.         // this down() migration is auto-generated, please modify it to your needs
  30.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql''Migration can only be executed safely on \'mysql\'.');
  31.         $this->addSql('ALTER TABLE std_content_types_attributes DROP PRIMARY KEY');
  32.         $this->addSql('ALTER TABLE std_content_types_attributes ADD content_type INT UNSIGNED NOT NULL COMMENT \'Unique identifier\', ADD attribute_id INT UNSIGNED NOT NULL COMMENT \'Attribute unique identifier\', DROP content_type_machine_name, DROP attribute_machine_name');
  33.         $this->addSql('ALTER TABLE std_content_types_attributes ADD CONSTRAINT FK_9CBB7EA741BCBAEC FOREIGN KEY (content_type) REFERENCES std_content_types (id)');
  34.         $this->addSql('ALTER TABLE std_content_types_attributes ADD CONSTRAINT FK_9CBB7EA7B6E62EFA FOREIGN KEY (attribute_id) REFERENCES std_attributes (id)');
  35.         $this->addSql('CREATE INDEX IDX_9CBB7EA741BCBAEC ON std_content_types_attributes (content_type)');
  36.         $this->addSql('CREATE INDEX IDX_9CBB7EA7B6E62EFA ON std_content_types_attributes (attribute_id)');
  37.         $this->addSql('ALTER TABLE std_content_types_attributes ADD PRIMARY KEY (content_type, attribute_id)');
  38.     }
  39. }