migrations/Version20250513072829.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.  * @author
  12.  * @internal
  13.  */
  14. final class Version20250513072829 extends AbstractMigration
  15. {
  16.     public function down(Schema $schema): void
  17.     {
  18.         // this down() migration is auto-generated, please modify it to your needs
  19.         $this->addSql(
  20.             '
  21.                 ALTER TABLE sob_task_type_l10n DROP FOREIGN KEY FK_87C0B5F4706E52B3
  22.             '
  23.         );
  24.         $this->addSql(
  25.             '
  26.                 ALTER TABLE sob_task_type_l10n DROP FOREIGN KEY FK_87C0B5F482F1BAF4
  27.             '
  28.         );
  29.         $this->addSql(
  30.             '
  31.                 DROP TABLE sob_task_type
  32.             '
  33.         );
  34.         $this->addSql(
  35.             '
  36.                 DROP TABLE sob_task_type_l10n
  37.             '
  38.         );
  39.     }
  40.     public function getDescription(): string
  41.     {
  42.         return
  43.             "- Introduces sob_task tables.";
  44.     }
  45.     public function up(Schema $schema): void
  46.     {
  47.         // this up() migration is auto-generated, please modify it to your needs
  48.         $this->addSql(
  49.             '
  50.                 CREATE TABLE sob_task_type (
  51.                     id INT AUTO_INCREMENT NOT NULL COMMENT \'Internal ID\',
  52.                     created INT NOT NULL COMMENT \'Entity creation date as UNIX timestamp\',
  53.                     active SMALLINT DEFAULT 1 NOT NULL COMMENT \'Indicator if entity is active\',
  54.                     last_active_date DATE DEFAULT NULL COMMENT \'Last active date\',
  55.                     PRIMARY KEY(id)
  56.                 ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB
  57.             '
  58.         );
  59.         $this->addSql(
  60.             '
  61.                 CREATE TABLE sob_task_type_l10n (
  62.                     parent_entity_id INT NOT NULL COMMENT \'Internal ID\',
  63.                     language_id VARCHAR(2) NOT NULL COMMENT \'Language code in lower case (ISO 639-1)\',
  64.                     name VARCHAR(225) DEFAULT NULL COMMENT \'Task type name in referenced language\',
  65.                     INDEX IDX_ECAD7EC5706E52B3 (parent_entity_id),
  66.                     INDEX IDX_ECAD7EC582F1BAF4 (language_id),
  67.                     PRIMARY KEY(parent_entity_id, language_id)
  68.                 ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB
  69.             '
  70.         );
  71.         $this->addSql(
  72.             '
  73.                 ALTER TABLE sob_task_type_l10n ADD CONSTRAINT FK_87C0B5F4706E52B3
  74.                     FOREIGN KEY (parent_entity_id) REFERENCES sob_task_type (id) ON DELETE CASCADE
  75.             '
  76.         );
  77.         $this->addSql(
  78.             '
  79.                 ALTER TABLE sob_task_type_l10n ADD CONSTRAINT FK_87C0B5F482F1BAF4
  80.                     FOREIGN KEY (language_id) REFERENCES language (id) ON DELETE CASCADE
  81.             '
  82.         );
  83.         $created time();
  84.         $this->addSql(
  85.             '
  86.                 INSERT INTO sob_task_type
  87.                     (id, created, active)
  88.                 VALUES
  89.                     (1, :createdTimeStamp, 1),
  90.                     (2, :createdTimeStamp, 1),
  91.                     (3, :createdTimeStamp, 1),
  92.                     (4, :createdTimeStamp, 1)
  93.                 ;
  94.             ',
  95.             ['createdTimeStamp' => $created]
  96.         );
  97.         $this->addSql(
  98.             '
  99.                 INSERT INTO sob_task_type_l10n
  100.                     (language_id, parent_entity_id, name)
  101.                 VALUES
  102.                     (\'de\', 1, \'Neuer Termin\'),
  103.                     (\'de\', 2, \'Kontakt Mitarbeiter\'),
  104.                     (\'de\', 3, \'Führungskraft kontaktieren\'),
  105.                     (\'de\', 4, \'Beratung überprüfen\'),
  106.                     (\'en\', 1, \'New appointment\'),
  107.                     (\'en\', 2, \'Contact employee\'),
  108.                     (\'en\', 3, \'Contact line manager\'),
  109.                     (\'en\', 4, \'Evaluate consulting progress\')
  110.                 ;
  111.             '
  112.         );
  113.     }
  114. }