migrations/Version20210909165508.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 Version20210909165508 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 std_attributes_content (id INT UNSIGNED AUTO_INCREMENT NOT NULL COMMENT \'Attribute content unique identifier\', attribute_id INT UNSIGNED DEFAULT NULL COMMENT \'Attribute unique identifier\', language_code VARCHAR(2) DEFAULT NULL COMMENT \'ISO 639 Language code\', created_by INT UNSIGNED DEFAULT NULL COMMENT \'Unique identifier\', updated_by INT UNSIGNED DEFAULT NULL COMMENT \'Unique identifier\', name VARCHAR(50) NOT NULL COMMENT \'Attribute name\', created_date DATETIME NOT NULL COMMENT \'Date and time of the record creation\', updated_date DATETIME NOT NULL COMMENT \'Date and time the record was last updated\', INDEX IDX_29AE36EDB6E62EFA (attribute_id), INDEX IDX_29AE36ED451CDAD4 (language_code), INDEX fk_std_attributes_std_users (created_by), INDEX fk_std_attributes_std_users_0 (updated_by), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
  20.         $this->addSql('CREATE TABLE std_attributes_values_content (id INT UNSIGNED AUTO_INCREMENT NOT NULL COMMENT \'Attribute value content unique identifier\', attribute_value_id INT UNSIGNED DEFAULT NULL COMMENT \'Attribute value unique identifier\', language_code VARCHAR(2) DEFAULT NULL COMMENT \'ISO 639 Language code\', label VARCHAR(255) NOT NULL COMMENT \'Attribute value label\', INDEX IDX_906D164565A22152 (attribute_value_id), INDEX IDX_906D1645451CDAD4 (language_code), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
  21.         $this->addSql('ALTER TABLE std_attributes_content ADD CONSTRAINT FK_29AE36EDB6E62EFA FOREIGN KEY (attribute_id) REFERENCES std_attributes (id)');
  22.         $this->addSql('ALTER TABLE std_attributes_content ADD CONSTRAINT FK_29AE36ED451CDAD4 FOREIGN KEY (language_code) REFERENCES std_languages (language_code)');
  23.         $this->addSql('ALTER TABLE std_attributes_content ADD CONSTRAINT FK_29AE36EDDE12AB56 FOREIGN KEY (created_by) REFERENCES std_users (id)');
  24.         $this->addSql('ALTER TABLE std_attributes_content ADD CONSTRAINT FK_29AE36ED16FE72E1 FOREIGN KEY (updated_by) REFERENCES std_users (id)');
  25.         $this->addSql('ALTER TABLE std_attributes_values_content ADD CONSTRAINT FK_906D164565A22152 FOREIGN KEY (attribute_value_id) REFERENCES std_attributes_values (id)');
  26.         $this->addSql('ALTER TABLE std_attributes_values_content ADD CONSTRAINT FK_906D1645451CDAD4 FOREIGN KEY (language_code) REFERENCES std_languages (language_code)');
  27.         $this->addSql('ALTER TABLE std_attributes_values CHANGE attribute_id attribute_id INT UNSIGNED DEFAULT NULL COMMENT \'Attribute unique identifier\'');
  28.         $this->addSql('ALTER TABLE std_attributes_values RENAME INDEX fk_std_attributes_values_std_attributes TO IDX_5C73E607B6E62EFA');
  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($this->connection->getDatabasePlatform()->getName() !== 'mysql''Migration can only be executed safely on \'mysql\'.');
  34.         $this->addSql('DROP TABLE std_attributes_content');
  35.         $this->addSql('DROP TABLE std_attributes_values_content');
  36.         $this->addSql('ALTER TABLE std_attributes_values CHANGE attribute_id attribute_id INT UNSIGNED NOT NULL COMMENT \'Attribute unique identifier\'');
  37.         $this->addSql('ALTER TABLE std_attributes_values RENAME INDEX idx_5c73e607b6e62efa TO FK_std_attributes_values_std_attributes');
  38.     }
  39. }