migrations/Version20230926123640.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 Version20230926123640 extends AbstractMigration
  14. {
  15.     public function down(Schema $schema): void
  16.     {
  17.         // this down() migration is auto-generated, please modify it to your needs
  18.         $this->addSql('ALTER TABLE ta_report DROP FOREIGN KEY FK_F777692B16D8554C');
  19.         $this->addSql('ALTER TABLE ta_report DROP FOREIGN KEY FK_F777692B7D182D95');
  20.         $this->addSql('ALTER TABLE ta_report DROP FOREIGN KEY FK_F777692BF3340201');
  21.         $this->addSql('ALTER TABLE ta_report DROP FOREIGN KEY FK_F777692BD669FA40');
  22.         $this->addSql('ALTER TABLE ta_report DROP FOREIGN KEY FK_F777692B468FF4C');
  23.         $this->addSql('DROP TABLE ta_report');
  24.     }
  25.     public function getDescription(): string
  26.     {
  27.         return
  28.             "- Introduces TA report table.";
  29.     }
  30.     public function up(Schema $schema): void
  31.     {
  32.         // this up() migration is auto-generated, please modify it to your needs
  33.         $this->addSql(
  34.             '
  35.                 CREATE TABLE ta_report (
  36.                     id INT AUTO_INCREMENT NOT NULL COMMENT \'Internal ID\',
  37.                     accident_id INT NOT NULL COMMENT \'Internal ID\',
  38.                     created_by_user_id INT NOT NULL COMMENT \'Internal ID\',
  39.                     insured_person_employee_legal_state_id VARCHAR(32) DEFAULT NULL
  40.                         COMMENT \'Internal employee legal state ID\',
  41.                     insured_person_gender_id VARCHAR(1) NOT NULL COMMENT \'Internal gender ID\',
  42.                     insured_person_nationality_id VARCHAR(2) DEFAULT NULL
  43.                         COMMENT \'Country code in upper case (ISO 3166-1 Alpha-2)\',
  44.                     created INT NOT NULL COMMENT \'Entity creation date as UNIX timestamp\',
  45.                     active SMALLINT DEFAULT 1 NOT NULL COMMENT \'Indicator if entity is active\',
  46.                     last_active_date DATE DEFAULT NULL COMMENT \'Last active date\',
  47.                     accident_date_time DATETIME NOT NULL COMMENT \'Accident date and time\',
  48.                     authorized_person_representative_full_name VARCHAR(500) NOT NULL
  49.                         COMMENT \'Full name of approving authorized person representative\',
  50.                     company_full_address VARCHAR(1000) NOT NULL COMMENT \'Company full address\',
  51.                     company_name VARCHAR(225) NOT NULL COMMENT \'Company name\',
  52.                     company_number VARCHAR(11) NOT NULL COMMENT \'Company number\',
  53.                     company_phone VARCHAR(225) DEFAULT NULL COMMENT \'Company phone number\',
  54.                     description TEXT NOT NULL COMMENT \'Description\',
  55.                     description_issuer_insured_person SMALLINT NOT NULL
  56.                         COMMENT \'Flag if description issuer was the insured person\',
  57.                     fatal SMALLINT NOT NULL COMMENT \'Flag if accident was fatal\',
  58.                     first_aid_full_address VARCHAR(1000) NOT NULL COMMENT \'First aid full address\',
  59.                     first_person_to_recognize_eyewitness SMALLINT DEFAULT NULL
  60.                         COMMENT \'Flag if first person to recognize was an eyewitness\',
  61.                     first_person_to_recognize_full_address VARCHAR(1000) DEFAULT NULL
  62.                         COMMENT \'First person to recognize full address\',
  63.                     injured_body_parts VARCHAR(2000) NOT NULL COMMENT \'Translated list of injured body parts\',
  64.                     injury_types VARCHAR(2000) NOT NULL COMMENT \'Translated list of injury types\',
  65.                     insured_person_address VARCHAR(225) NOT NULL COMMENT \'Postal address for insured person\',
  66.                     insured_person_birthday DATE NOT NULL COMMENT \'Insured person birthday\',
  67.                     insured_person_city VARCHAR(225) NOT NULL COMMENT \'City of address for insured person\',
  68.                     insured_person_external_worker SMALLINT NOT NULL
  69.                         COMMENT \'Flag if insured person is an external worker\',
  70.                     insured_person_full_name VARCHAR(500) NOT NULL COMMENT \'Insured person full name\',
  71.                     insured_person_health_insurance_provider_full_address VARCHAR(1000) NOT NULL
  72.                         COMMENT \'Insured person health insurance provider full address\',
  73.                     insured_person_job_entry_date DATE DEFAULT NULL COMMENT \'Insured person job entry date\',
  74.                     insured_person_job_title VARCHAR(225) DEFAULT NULL COMMENT \'Insured person job title\',
  75.                     insured_person_org_unit_name VARCHAR(225) NOT NULL COMMENT \'Insured person org unit name\',
  76.                     insured_person_restarted_working_date DATE DEFAULT NULL
  77.                         COMMENT \'Date when insured person restarted working\',
  78.                     insured_person_stopped_working SMALLINT NOT NULL
  79.                         COMMENT \'Flag if insured person stopped working after accident\',
  80.                     insured_person_stopped_working_date_time DATETIME DEFAULT NULL
  81.                         COMMENT \'Date and time when insured person stopped working\',
  82.                     insured_person_trainee SMALLINT NOT NULL COMMENT \'Flag if insured person is a trainee\',
  83.                     insured_person_weeks_sick_leave INT NOT NULL COMMENT \'Weeks of sick leave for insured person\',
  84.                     insured_person_work_ending_time TIME NOT NULL COMMENT \'Work ending time of insured person\',
  85.                     insured_person_work_starting_time TIME NOT NULL COMMENT \'Work starting time of insured person\',
  86.                     insured_person_zip_code VARCHAR(16) NOT NULL COMMENT \'Zip code of address for insured person\',
  87.                     place VARCHAR(1000) NOT NULL COMMENT \'Place\',
  88.                     receiver_full_address VARCHAR(1000) NOT NULL COMMENT \'Receiver full address\',
  89.                     receiver_name VARCHAR(225) NOT NULL COMMENT \'Receiver name\',
  90.                     work_council_representative_full_name VARCHAR(500) DEFAULT NULL
  91.                         COMMENT \'Full name of approving work council representative\',
  92.                     UNIQUE INDEX UNIQ_F777692B16D8554C (accident_id),
  93.                     INDEX IDX_F777692B7D182D95 (created_by_user_id),
  94.                     INDEX IDX_F777692BF3340201 (insured_person_employee_legal_state_id),
  95.                     INDEX IDX_F777692BD669FA40 (insured_person_gender_id),
  96.                     INDEX IDX_F777692B468FF4C (insured_person_nationality_id),
  97.                     PRIMARY KEY(id)
  98.                 ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB
  99.             '
  100.         );
  101.         $this->addSql(
  102.             '
  103.                 ALTER TABLE ta_report ADD CONSTRAINT FK_F777692B16D8554C
  104.                     FOREIGN KEY (accident_id) REFERENCES accident (id) ON DELETE CASCADE
  105.             '
  106.         );
  107.         $this->addSql(
  108.             '
  109.                 ALTER TABLE ta_report ADD CONSTRAINT FK_F777692B7D182D95
  110.                     FOREIGN KEY (created_by_user_id) REFERENCES user (id)
  111.             '
  112.         );
  113.         $this->addSql(
  114.             '
  115.                 ALTER TABLE ta_report ADD CONSTRAINT FK_F777692BF3340201
  116.                     FOREIGN KEY (insured_person_employee_legal_state_id) REFERENCES employee_legal_state (id)
  117.             '
  118.         );
  119.         $this->addSql(
  120.             '
  121.                 ALTER TABLE ta_report ADD CONSTRAINT FK_F777692BD669FA40
  122.                     FOREIGN KEY (insured_person_gender_id) REFERENCES gender (id)
  123.             '
  124.         );
  125.         $this->addSql(
  126.             '
  127.                 ALTER TABLE ta_report ADD CONSTRAINT FK_F777692B468FF4C
  128.                     FOREIGN KEY (insured_person_nationality_id) REFERENCES country (id)
  129.             '
  130.         );
  131.     }
  132. }