migrations/Version20230503081202.php line 1

Open in your IDE?
  1. <?php
  2. /* @noinspection PhpUnused */
  3. declare(strict_types=1);
  4. namespace DoctrineMigrations;
  5. use Doctrine\DBAL\Schema\Schema;
  6. use Doctrine\Migrations\AbstractMigration;
  7. /**
  8.  * Auto-generated Migration: Please modify to your needs!
  9.  *
  10.  * @package API
  11.  * @internal
  12.  */
  13. final class Version20230503081202 extends AbstractMigration
  14. {
  15.     public function getDescription(): string
  16.     {
  17.         return
  18.             "- Introduces OIM status table and localizations.";
  19.     }
  20.     public function up(Schema $schema): void
  21.     {
  22.         // this up() migration is auto-generated, please modify it to your needs
  23.         $this->addSql(
  24.             '
  25.                 CREATE TABLE oim_status (
  26.                     id INT AUTO_INCREMENT NOT NULL COMMENT \'Internal ID\',
  27.                     created INT NOT NULL COMMENT \'Entity creation date as UNIX timestamp\',
  28.                     active SMALLINT DEFAULT 1 NOT NULL COMMENT \'Indicator if entity is active\',
  29.                     internal_status_id VARCHAR(16) NOT NULL COMMENT \'Internal status ID\',
  30.                     INDEX IDX_6717E8FFE330F8D6 (internal_status_id),
  31.                     PRIMARY KEY(id)
  32.                 ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB;
  33.             '
  34.         );
  35.         $this->addSql(
  36.             '
  37.                 CREATE TABLE oim_status_l10n (
  38.                     parent_entity_id INT NOT NULL COMMENT \'Internal ID\',
  39.                     language_id VARCHAR(2) NOT NULL COMMENT \'Language code in lower case (ISO 639-1)\',
  40.                     name VARCHAR(225) DEFAULT NULL COMMENT \'Status name in referenced language\',
  41.                     INDEX IDX_B70EF479706E52B3 (parent_entity_id),
  42.                     INDEX IDX_B70EF47982F1BAF4 (language_id),
  43.                     PRIMARY KEY(parent_entity_id, language_id)
  44.                 ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB;
  45.             '
  46.         );
  47.         $this->addSql(
  48.             '
  49.                 ALTER TABLE oim_status ADD CONSTRAINT FK_6717E8FFE330F8D6 FOREIGN KEY
  50.                     (internal_status_id) REFERENCES oim_internal_status (id);
  51.             '
  52.         );
  53.         $this->addSql(
  54.             '
  55.                 ALTER TABLE oim_status_l10n ADD CONSTRAINT FK_B70EF479706E52B3 FOREIGN KEY
  56.                     (parent_entity_id) REFERENCES oim_status (id) ON DELETE CASCADE;
  57.             '
  58.         );
  59.         $this->addSql(
  60.             '
  61.                 ALTER TABLE oim_status_l10n ADD CONSTRAINT FK_B70EF47982F1BAF4 FOREIGN KEY
  62.                     (language_id) REFERENCES language (id) ON DELETE CASCADE;
  63.             '
  64.         );
  65.     }
  66.     public function down(Schema $schema): void
  67.     {
  68.         // this down() migration is auto-generated, please modify it to your needs
  69.         $this->addSql('ALTER TABLE oim_status_l10n DROP FOREIGN KEY FK_B70EF479706E52B3');
  70.         $this->addSql('ALTER TABLE oim_status_l10n DROP FOREIGN KEY FK_B70EF47982F1BAF4');
  71.         $this->addSql('DROP TABLE oim_status_l10n');
  72.         $this->addSql('ALTER TABLE oim_status DROP FOREIGN KEY FK_6717E8FFE330F8D6');
  73.         $this->addSql('DROP TABLE oim_status');
  74.     }
  75. }