<?php
/* @noinspection PhpUnused */
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*
* @package API
* @internal
*/
final class Version20230224113411 extends AbstractMigration
{
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE accident DROP FOREIGN KEY FK_8F31DB6FA7ECE841');
$this->addSql('ALTER TABLE accident DROP FOREIGN KEY FK_8F31DB6F8C03F15C');
$this->addSql('ALTER TABLE accident DROP FOREIGN KEY FK_8F31DB6FD3C69772');
$this->addSql('ALTER TABLE accident DROP FOREIGN KEY FK_8F31DB6FB996D56C');
$this->addSql('ALTER TABLE accident DROP FOREIGN KEY FK_8F31DB6FDB3BF2E8');
$this->addSql('ALTER TABLE accident DROP FOREIGN KEY FK_8F31DB6F8B66BF13');
$this->addSql('ALTER TABLE accident DROP FOREIGN KEY FK_8F31DB6F7D182D95');
$this->addSql('ALTER TABLE accident DROP FOREIGN KEY FK_8F31DB6F2793CC5E');
$this->addSql('ALTER TABLE accident DROP FOREIGN KEY FK_8F31DB6F9D1A2C23');
$this->addSql('ALTER TABLE accident_injury DROP FOREIGN KEY FK_5F05591516D8554C');
$this->addSql('ALTER TABLE accident_injury DROP FOREIGN KEY FK_5F055915A515F27A');
$this->addSql('ALTER TABLE accident_injury DROP FOREIGN KEY FK_5F05591530AF3734');
$this->addSql('ALTER TABLE accident_protective_gear DROP FOREIGN KEY FK_8F62F2A016D8554C');
$this->addSql('ALTER TABLE accident_protective_gear DROP FOREIGN KEY FK_8F62F2A0190B0335');
$this->addSql('DROP TABLE accident');
$this->addSql('DROP TABLE accident_injury');
$this->addSql('DROP TABLE accident_protective_gear');
}
public function getDescription(): string
{
return
"Introduces accident table.\n" .
"Introduces accident_protective_gear table.\n" .
"Introduces accident_injury table.";
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql(
'
CREATE TABLE accident (
id INT AUTO_INCREMENT NOT NULL COMMENT \'Internal ID\',
accident_status_id VARCHAR(32) NOT NULL COMMENT \'Internal accident status ID\',
employee_id INT DEFAULT NULL COMMENT \'Internal ID\',
casualty_gender_id VARCHAR(1) NOT NULL COMMENT \'Internal gender ID\',
casualty_nationality_id VARCHAR(2) DEFAULT NULL
COMMENT \'Country code in upper case (ISO 3166-1 Alpha-2)\',
casualty_employee_type_id VARCHAR(16) NOT NULL COMMENT \'Internal employee type ID\',
casualty_employee_legal_state_id VARCHAR(32) DEFAULT NULL
COMMENT \'Internal employee legal state ID\',
created_by_user_id INT NOT NULL COMMENT \'Internal ID\',
updated_by_user_id INT DEFAULT NULL COMMENT \'Internal ID\',
created INT NOT NULL COMMENT \'Entity creation date as UNIX timestamp\',
active SMALLINT DEFAULT 1 NOT NULL COMMENT \'Indicator if entity is active\',
casualty_birthday DATE NOT NULL COMMENT \'Casualty birthday\',
casualty_last_name VARCHAR(225) NOT NULL COMMENT \'Casualty last name\',
casualty_first_name VARCHAR(225) NOT NULL COMMENT \'Casualty first name\',
casualty_address VARCHAR(225) NOT NULL COMMENT \'Postal address for casualty\',
casualty_zip_code VARCHAR(16) NOT NULL COMMENT \'Zip code of address for casualty\',
casualty_city VARCHAR(225) NOT NULL COMMENT \'City of address for casualty\',
casualty_health_insurance_provider_full_address VARCHAR(1000) NOT NULL
COMMENT \'Casualty health insurance provider full address\',
casualty_job_title VARCHAR(225) DEFAULT NULL COMMENT \'Casualty job title\',
casualty_job_entry_date DATE DEFAULT NULL COMMENT \'Casualty job entry date\',
casualty_org_unit_name VARCHAR(225) NOT NULL COMMENT \'Casualty org unit name\',
accident_type SMALLINT NOT NULL COMMENT \'Flag for accident type\',
accident_date_time DATETIME NOT NULL COMMENT \'Accident date and time\',
accident_org_unit_name VARCHAR(225) NOT NULL COMMENT \'Accident org unit name\',
accident_org_unit_id INT NOT NULL COMMENT \'Internal ID\',
place VARCHAR(1000) DEFAULT NULL COMMENT \'Place\',
description TEXT NOT NULL COMMENT \'Description\',
fatal SMALLINT NOT NULL COMMENT \'Flag if accident was fatal\',
accident_in_home_office SMALLINT NOT NULL COMMENT \'Flag if accident happened in the home office\',
description_issuer_casualty SMALLINT NOT NULL
COMMENT \'Flag if description issuer was the casualty\',
first_person_to_recognize_full_address VARCHAR(1000) DEFAULT NULL
COMMENT \'First person to recognize full address\',
first_person_to_recognize_eyewitness SMALLINT DEFAULT NULL
COMMENT \'Flag if first person to recognize was an eyewitness\',
first_aid_full_address VARCHAR(1000) DEFAULT NULL COMMENT \'First aid full address\',
casualty_work_starting_time TIME NOT NULL COMMENT \'Working day start time of casualty\',
casualty_work_ending_time TIME NOT NULL COMMENT \'Working day end time of casualty\',
casualty_stopped_working SMALLINT NOT NULL
COMMENT \'Flag if casualty stopped working after accident\',
casualty_stopped_working_date_time DATETIME DEFAULT NULL
COMMENT \'Date and time when casualty stopped working\',
casualty_restarted_working_date DATE DEFAULT NULL COMMENT \'Date when casualty restarted working\',
casualty_lost_days INT DEFAULT NULL COMMENT \'Lost working days for casualty\',
authorized_person_representative_full_name VARCHAR(500) DEFAULT NULL
COMMENT \'Full name of approving authorized person representative\',
work_council_representative_full_name VARCHAR(500) DEFAULT NULL
COMMENT \'Full name of approving work council representative\',
updated INT DEFAULT NULL COMMENT \'Last accident update date as UNIX timestamp\',
last_active_date DATE DEFAULT NULL COMMENT \'Last active date\',
INDEX IDX_8F31DB6FA7ECE841 (accident_status_id),
INDEX IDX_8F31DB6F8C03F15C (employee_id),
INDEX IDX_8F31DB6FD3C69772 (casualty_gender_id),
INDEX IDX_8F31DB6FB996D56C (casualty_nationality_id),
INDEX IDX_8F31DB6FDB3BF2E8 (casualty_employee_type_id),
INDEX IDX_8F31DB6F8B66BF13 (casualty_employee_legal_state_id),
INDEX IDX_8F31DB6F7D182D95 (created_by_user_id),
INDEX IDX_8F31DB6F2793CC5E (updated_by_user_id),
INDEX IDX_8F31DB6F9D1A2C23 (accident_org_unit_id),
PRIMARY KEY(id)
) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB
'
);
$this->addSql(
'
CREATE TABLE accident_injury (
accident_id INT NOT NULL COMMENT \'Internal ID\',
body_part_id VARCHAR(16) NOT NULL COMMENT \'Internal body part ID\',
injury_type_id VARCHAR(32) NOT NULL COMMENT \'Internal injury type ID\',
INDEX IDX_5F05591516D8554C (accident_id),
INDEX IDX_5F055915A515F27A (body_part_id),
INDEX IDX_5F05591530AF3734 (injury_type_id),
PRIMARY KEY(accident_id, body_part_id, injury_type_id)
) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB
'
);
$this->addSql(
'
CREATE TABLE accident_protective_gear (
accident_id INT NOT NULL COMMENT \'Internal ID\',
protective_gear_id INT NOT NULL COMMENT \'Internal ID\',
INDEX IDX_8F62F2A016D8554C (accident_id),
INDEX IDX_8F62F2A0190B0335 (protective_gear_id),
PRIMARY KEY(accident_id, protective_gear_id)
) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB
'
);
$this->addSql(
'
ALTER TABLE accident ADD CONSTRAINT FK_8F31DB6FA7ECE841 FOREIGN KEY
(accident_status_id) REFERENCES accident_status (id)
'
);
$this->addSql(
'
ALTER TABLE accident ADD CONSTRAINT FK_8F31DB6F8C03F15C FOREIGN KEY
(employee_id) REFERENCES employee (id)
'
);
$this->addSql(
'
ALTER TABLE accident ADD CONSTRAINT FK_8F31DB6FD3C69772 FOREIGN KEY
(casualty_gender_id) REFERENCES gender (id)
'
);
$this->addSql(
'
ALTER TABLE accident ADD CONSTRAINT FK_8F31DB6FB996D56C FOREIGN KEY
(casualty_nationality_id) REFERENCES country (id)
'
);
$this->addSql(
'
ALTER TABLE accident ADD CONSTRAINT FK_8F31DB6FDB3BF2E8 FOREIGN KEY
(casualty_employee_type_id) REFERENCES employee_type (id)
'
);
$this->addSql(
'
ALTER TABLE accident ADD CONSTRAINT FK_8F31DB6F8B66BF13 FOREIGN KEY
(casualty_employee_legal_state_id) REFERENCES employee_legal_state (id)
'
);
$this->addSql(
'
ALTER TABLE accident ADD CONSTRAINT FK_8F31DB6F7D182D95 FOREIGN KEY
(created_by_user_id) REFERENCES user (id)
'
);
$this->addSql(
'
ALTER TABLE accident ADD CONSTRAINT FK_8F31DB6F2793CC5E FOREIGN KEY
(updated_by_user_id) REFERENCES user (id)
'
);
$this->addSql(
'
ALTER TABLE accident ADD CONSTRAINT FK_8F31DB6F9D1A2C23 FOREIGN KEY
(accident_org_unit_id) REFERENCES org_unit (id)
'
);
$this->addSql(
'
ALTER TABLE accident_injury ADD CONSTRAINT FK_5F05591516D8554C FOREIGN KEY
(accident_id) REFERENCES accident (id) ON DELETE CASCADE
'
);
$this->addSql(
'
ALTER TABLE accident_injury ADD CONSTRAINT FK_5F055915A515F27A FOREIGN KEY
(body_part_id) REFERENCES body_part (id)
'
);
$this->addSql(
'
ALTER TABLE accident_injury ADD CONSTRAINT FK_5F05591530AF3734 FOREIGN KEY
(injury_type_id) REFERENCES injury_type (id)
'
);
$this->addSql(
'
ALTER TABLE accident_protective_gear ADD CONSTRAINT FK_8F62F2A016D8554C FOREIGN KEY
(accident_id) REFERENCES accident (id) ON DELETE CASCADE
'
);
$this->addSql(
'
ALTER TABLE accident_protective_gear ADD CONSTRAINT FK_8F62F2A0190B0335 FOREIGN KEY
(protective_gear_id) REFERENCES protective_gear (id)
'
);
}
}