migrations/Version20250413153549.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 Version20250413153549 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->addSql(
  19.             "
  20.                 CREATE TABLE sob_reason (
  21.                     id INT AUTO_INCREMENT NOT NULL COMMENT 'Internal ID', 
  22.                     created INT NOT NULL COMMENT 'Entity creation date as UNIX timestamp', 
  23.                     active SMALLINT DEFAULT 1 NOT NULL COMMENT 'Indicator if entity is active', 
  24.                     last_active_date DATE DEFAULT NULL COMMENT 'Last active date', 
  25.                     PRIMARY KEY(id)
  26.                 ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB
  27.                 "
  28.         );
  29.         $this->addSql(
  30.             "
  31.                 CREATE TABLE sob_reason_l10n (
  32.                     parent_entity_id INT NOT NULL COMMENT 'Internal ID', 
  33.                     language_id VARCHAR(2) NOT NULL COMMENT 'Language code in lower case (ISO 639-1)', 
  34.                     name VARCHAR(225) DEFAULT NULL COMMENT 'Reason name in referenced language', 
  35.                     INDEX IDX_16EAB29B706E52B3 (parent_entity_id), 
  36.                     INDEX IDX_16EAB29B82F1BAF4 (language_id), 
  37.                     PRIMARY KEY(parent_entity_id, language_id)
  38.                 ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB
  39.                 "
  40.         );
  41.         $this->addSql(
  42.             "
  43.                 ALTER TABLE sob_reason_l10n ADD CONSTRAINT FK_16EAB29B706E52B3 FOREIGN KEY 
  44.                 (parent_entity_id) REFERENCES sob_reason (id) ON DELETE CASCADE
  45.                 "
  46.         );
  47.         $this->addSql(
  48.             "
  49.                 ALTER TABLE sob_reason_l10n ADD CONSTRAINT FK_16EAB29B82F1BAF4 FOREIGN KEY 
  50.                 (language_id) REFERENCES language (id) ON DELETE CASCADE
  51.                 "
  52.         );
  53.         $created time();
  54.         $this->addSql(
  55.             '
  56.                 INSERT INTO sob_reason
  57.                     (id, created, active)
  58.                 VALUES
  59.                     (1, :createdTimeStamp, 1),
  60.                     (2, :createdTimeStamp, 1),
  61.                     (3, :createdTimeStamp, 1),
  62.                     (4, :createdTimeStamp, 1),
  63.                     (5, :createdTimeStamp, 1),
  64.                     (6, :createdTimeStamp, 1),
  65.                     (7, :createdTimeStamp, 1),
  66.                     (8, :createdTimeStamp, 1),
  67.                     (9, :createdTimeStamp, 1),
  68.                     (10, :createdTimeStamp, 1),
  69.                     (11, :createdTimeStamp, 1),
  70.                     (12, :createdTimeStamp, 1)
  71.                 ;
  72.             ',
  73.             ['createdTimeStamp' => $created]
  74.         );
  75.         $this->addSql(
  76.             '
  77.                 INSERT INTO sob_reason_l10n
  78.                     (language_id, parent_entity_id, name)
  79.                 VALUES
  80.                     (\'de\', 1, \'Abhängigkeit/Missbrauch\'),
  81.                     (\'de\', 2, \'Arbeitseinsatz\'),
  82.                     (\'de\', 3, \'Arbeitsleistung/-qualität\'),
  83.                     (\'de\', 4, \'Arbeitsplatz\'),
  84.                     (\'de\', 5, \'Arbeitssicherheit\'),
  85.                     (\'de\', 6, \'Burnout\'),
  86.                     (\'de\', 7, \'Arbeitsüberlastung\'),
  87.                     (\'de\', 8, \'Fehlzeiten\'),
  88.                     (\'de\', 9, \'Konflikte am Arbeitsplatz\'),
  89.                     (\'de\', 10, \'Persönliche Themen\'),
  90.                     (\'de\', 11, \'Schichtarbeit\'),
  91.                     (\'de\', 12, \'Psychische Themen\'),
  92.                     (\'en\', 1, \'Substance Abuse\'),
  93.                     (\'en\', 2, \'Job Assignment\'),
  94.                     (\'en\', 3, \'Work Performance and Quality\'),
  95.                     (\'en\', 4, \'Workplace\'),
  96.                     (\'en\', 5, \'Safety at Work\'),
  97.                     (\'en\', 6, \'Burnout\'),
  98.                     (\'en\', 7, \'Workload & Overload\'),
  99.                     (\'en\', 8, \'Absence\'),
  100.                     (\'en\', 9, \'Conflicts\'),
  101.                     (\'en\', 10, \'Personal Issues\'),
  102.                     (\'en\', 11, \'Shift Work\'),
  103.                     (\'en\', 12, \'Mental and Psychological Issues\')
  104.                 ;
  105.             '
  106.         );
  107.     }
  108.     public function down(Schema $schema): void
  109.     {
  110.         // this down() migration is auto-generated, please modify it to your needs
  111.         $this->addSql(
  112.             "
  113.                 ALTER TABLE sob_reason_l10n DROP FOREIGN KEY FK_16EAB29B706E52B3
  114.                 "
  115.             );
  116.         $this->addSql(
  117.             "
  118.             ALTER TABLE sob_reason_l10n DROP FOREIGN KEY FK_16EAB29B82F1BAF4
  119.             "
  120.         );
  121.         $this->addSql(
  122.             "
  123.             DROP TABLE sob_reason
  124.             "
  125.         );
  126.         $this->addSql(
  127.             "
  128.             DROP TABLE sob_reason_l10n
  129.             "
  130.         );
  131.     }
  132. }