migrations/Version20230505090121.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. final class Version20230505090121 extends AbstractMigration
  11. {
  12.     public function getDescription(): string
  13.     {
  14.         return '';
  15.     }
  16.     public function up(Schema $schema): void
  17.     {
  18.         // this up() migration is auto-generated, please modify it to your needs
  19.         $this->addSql(
  20.             '
  21.                 CREATE TABLE oim_measure_category (
  22.                     id INT AUTO_INCREMENT NOT NULL COMMENT \'Internal ID\',
  23.                     created INT NOT NULL COMMENT \'Entity creation date as UNIX timestamp\',
  24.                     active SMALLINT DEFAULT 1 NOT NULL COMMENT \'Indicator if entity is active\',
  25.                     last_active_date DATE DEFAULT NULL COMMENT \'Last active date\',
  26.                     PRIMARY KEY(id)
  27.                 ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB;
  28.             '
  29.         );
  30.         $this->addSql(
  31.             '
  32.                 CREATE TABLE oim_measure_category_l10n (
  33.                     parent_entity_id INT NOT NULL COMMENT \'Internal ID\',
  34.                     language_id VARCHAR(2) NOT NULL COMMENT \'Language code in lower case (ISO 639-1)\',
  35.                     name VARCHAR(225) DEFAULT NULL COMMENT \'Measure category name in referenced language\',
  36.                     INDEX IDX_B49D7E35706E52B3 (parent_entity_id),
  37.                     INDEX IDX_B49D7E3582F1BAF4 (language_id),
  38.                     PRIMARY KEY(parent_entity_id, language_id)
  39.                 ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB;
  40.             '
  41.         );
  42.         $this->addSql(
  43.             '
  44.                 CREATE TABLE oim_measure (
  45.                     id INT AUTO_INCREMENT NOT NULL COMMENT \'Internal ID\',
  46.                     category_id INT NOT NULL COMMENT \'Internal ID\',
  47.                     created INT NOT NULL COMMENT \'Entity creation date as UNIX timestamp\',
  48.                     active SMALLINT DEFAULT 1 NOT NULL COMMENT \'Indicator if entity is active\',
  49.                     last_active_date DATE DEFAULT NULL COMMENT \'Last active date\',
  50.                     INDEX IDX_B918BD6A12469DE2 (category_id),
  51.                     PRIMARY KEY(id)
  52.                 ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB;
  53.             '
  54.         );
  55.         $this->addSql(
  56.             '
  57.                 CREATE TABLE oim_measure_l10n (parent_entity_id INT NOT NULL COMMENT \'Internal ID\',
  58.                     language_id VARCHAR(2) NOT NULL COMMENT \'Language code in lower case (ISO 639-1)\',
  59.                     name VARCHAR(225) DEFAULT NULL COMMENT \'Measure name in referenced language\',
  60.                     INDEX IDX_46DC0C25706E52B3 (parent_entity_id),
  61.                     INDEX IDX_46DC0C2582F1BAF4 (language_id),
  62.                     PRIMARY KEY(parent_entity_id, language_id)
  63.                 ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB;
  64.             '
  65.         );
  66.         $this->addSql(
  67.             '
  68.                 CREATE TABLE oim_measures (
  69.                     id INT AUTO_INCREMENT NOT NULL COMMENT \'Internal ID\',
  70.                     oim_case_id INT NOT NULL COMMENT \'Internal ID\',
  71.                     social_security_agency_id INT DEFAULT NULL COMMENT \'Internal ID\',
  72.                     created INT NOT NULL COMMENT \'Entity creation date as UNIX timestamp\',
  73.                     active SMALLINT DEFAULT 1 NOT NULL COMMENT \'Indicator if entity is active\',
  74.                     description VARCHAR(225) NOT NULL COMMENT \'description of this measure\',
  75.                     date_from DATETIME DEFAULT NULL COMMENT \'start date of measure\',
  76.                     date_to DATETIME DEFAULT NULL COMMENT \'end date of measure\',
  77.                     finish_comment VARCHAR(225) NOT NULL COMMENT \'comment after finished measure\',
  78.                     INDEX IDX_B6D05FF0F60F70BA (oim_case_id),
  79.                     INDEX IDX_B6D05FF0F6023175 (social_security_agency_id),
  80.                     PRIMARY KEY(id)
  81.                 ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB
  82.             '
  83.         );
  84.         $this->addSql(
  85.             '
  86.                 ALTER TABLE oim_measure_category_l10n ADD CONSTRAINT FK_B49D7E35706E52B3 FOREIGN KEY
  87.                     (parent_entity_id) REFERENCES oim_measure_category (id) ON DELETE CASCADE;
  88.             '
  89.         );
  90.         $this->addSql(
  91.             '
  92.                 ALTER TABLE oim_measure_category_l10n ADD CONSTRAINT FK_B49D7E3582F1BAF4 FOREIGN KEY
  93.                     (language_id) REFERENCES language (id) ON DELETE CASCADE;
  94.             '
  95.         );
  96.         $this->addSql(
  97.             '
  98.                 ALTER TABLE oim_measure ADD CONSTRAINT FK_B918BD6A12469DE2 FOREIGN KEY
  99.                     (category_id) REFERENCES oim_measure_category (id);
  100.             '
  101.         );
  102.         $this->addSql(
  103.             '
  104.                 ALTER TABLE oim_measure_l10n ADD CONSTRAINT FK_46DC0C25706E52B3 FOREIGN KEY
  105.                     (parent_entity_id) REFERENCES oim_measure (id) ON DELETE CASCADE;
  106.             '
  107.         );
  108.         $this->addSql(
  109.             '
  110.                 ALTER TABLE oim_measure_l10n ADD CONSTRAINT FK_46DC0C2582F1BAF4 FOREIGN KEY
  111.                     (language_id) REFERENCES language (id) ON DELETE CASCADE;
  112.             '
  113.         );
  114.         $this->addSql(
  115.             '
  116.                 ALTER TABLE oim_measures ADD CONSTRAINT FK_B6D05FF0F60F70BA
  117.                     FOREIGN KEY (oim_case_id) REFERENCES oim_case (id) ON DELETE CASCADE;
  118.             '
  119.         );
  120.         $this->addSql(
  121.             '
  122.                 ALTER TABLE oim_measures ADD CONSTRAINT FK_B6D05FF0F6023175 FOREIGN KEY
  123.                     (social_security_agency_id) REFERENCES social_security_agency (id)
  124.             '
  125.         );
  126.         $this->addSql(
  127.             '
  128.                 ALTER TABLE oim_conversations CHANGE conversation_notes
  129.                     conversation_notes VARCHAR(225) NOT NULL COMMENT \'Notes of this conversation\'
  130.             '
  131.         );
  132.     }
  133.     public function down(Schema $schema): void
  134.     {
  135.         // this down() migration is auto-generated, please modify it to your needs
  136.         $this->addSql('ALTER TABLE oim_measure_category_l10n DROP FOREIGN KEY FK_B49D7E35706E52B3');
  137.         $this->addSql('ALTER TABLE oim_measure_category_l10n DROP FOREIGN KEY FK_B49D7E3582F1BAF4');
  138.         $this->addSql('ALTER TABLE oim_measure DROP FOREIGN KEY FK_B918BD6A12469DE2');
  139.         $this->addSql('ALTER TABLE oim_measure_l10n DROP FOREIGN KEY FK_46DC0C25706E52B3');
  140.         $this->addSql('ALTER TABLE oim_measure_l10n DROP FOREIGN KEY FK_46DC0C2582F1BAF4');
  141.         $this->addSql('ALTER TABLE oim_measures DROP FOREIGN KEY FK_B6D05FF0F60F70BA');
  142.         $this->addSql('ALTER TABLE oim_measures DROP FOREIGN KEY FK_B6D05FF0F6023175');
  143.         $this->addSql('DROP TABLE oim_measure_l10n');
  144.         $this->addSql('DROP TABLE oim_measure');
  145.         $this->addSql('DROP TABLE oim_measure_category_l10n');
  146.         $this->addSql('DROP TABLE oim_measure_category');
  147.         $this->addSql('DROP TABLE oim_measures');
  148.         $this->addSql(
  149.             '
  150.                 ALTER TABLE oim_conversations CHANGE conversation_notes
  151.                     conversation_notes VARCHAR(225) DEFAULT NULL COMMENT \'Notes of this conversation\'
  152.             '
  153.         );
  154.     }
  155. }