migrations/Version20230505090120.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 Version20230505090120 extends AbstractMigration
  14. {
  15.     public function getDescription(): string
  16.     {
  17.         return
  18.             "- Introduces social security agency 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 social_security_agency (
  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.                     last_active_date DATE DEFAULT NULL COMMENT \'Last active date\',
  30.                     PRIMARY KEY(id)
  31.                 ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB;
  32.             '
  33.         );
  34.         $this->addSql(
  35.             '
  36.                 CREATE TABLE social_security_agency_l10n (
  37.                     parent_entity_id INT NOT NULL COMMENT \'Internal ID\',
  38.                     language_id VARCHAR(2) NOT NULL COMMENT \'Language code in lower case (ISO 639-1)\',
  39.                     name VARCHAR(225) DEFAULT NULL COMMENT \'Social security agency name in referenced language\',
  40.                     INDEX IDX_6AAA0FB1706E52B3 (parent_entity_id),
  41.                     INDEX IDX_6AAA0FB182F1BAF4 (language_id),
  42.                     PRIMARY KEY(parent_entity_id, language_id)
  43.                 ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB;
  44.             '
  45.         );
  46.         $this->addSql(
  47.             '
  48.                 ALTER TABLE social_security_agency_l10n ADD CONSTRAINT FK_6AAA0FB1706E52B3 FOREIGN KEY
  49.                     (parent_entity_id) REFERENCES social_security_agency (id) ON DELETE CASCADE
  50.             '
  51.         );
  52.         $this->addSql(
  53.             '
  54.                 ALTER TABLE social_security_agency_l10n ADD CONSTRAINT FK_6AAA0FB182F1BAF4 FOREIGN KEY
  55.                     (language_id) REFERENCES language (id) ON DELETE CASCADE
  56.             '
  57.         );
  58.     }
  59.     public function down(Schema $schema): void
  60.     {
  61.         // this down() migration is auto-generated, please modify it to your needs
  62.         $this->addSql('ALTER TABLE social_security_agency_l10n DROP FOREIGN KEY FK_6AAA0FB1706E52B3');
  63.         $this->addSql('ALTER TABLE social_security_agency_l10n DROP FOREIGN KEY FK_6AAA0FB182F1BAF4');
  64.         $this->addSql('DROP TABLE social_security_agency');
  65.         $this->addSql('DROP TABLE social_security_agency_l10n');
  66.     }
  67. }