<?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 Version20220718134633 extends AbstractMigration
{
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE employee DROP FOREIGN KEY FK_5D9F75A1708A0E0');
$this->addSql('ALTER TABLE employee DROP FOREIGN KEY FK_5D9F75A1F92F3E70');
$this->addSql('ALTER TABLE employee DROP FOREIGN KEY FK_5D9F75A1398C36DB');
$this->addSql('ALTER TABLE employee DROP FOREIGN KEY FK_5D9F75A11C9DA55');
$this->addSql('ALTER TABLE employee DROP FOREIGN KEY FK_5D9F75A14500DA9C');
$this->addSql('ALTER TABLE employee DROP FOREIGN KEY FK_5D9F75A19CADC2E8');
$this->addSql('ALTER TABLE employee DROP FOREIGN KEY FK_5D9F75A18BC224C3');
$this->addSql('ALTER TABLE org_unit DROP FOREIGN KEY FK_455318CB727ACA70');
$this->addSql('ALTER TABLE org_unit DROP FOREIGN KEY FK_455318CBE9A65564');
$this->addSql('ALTER TABLE org_unit DROP FOREIGN KEY FK_455318CB9B60D4F0');
$this->addSql('DROP TABLE employee');
$this->addSql('DROP TABLE org_unit');
}
public function getDescription(): string
{
return
"- Introduces employee table\n" .
"- Introduces org_unit table";
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql(
'
CREATE TABLE employee (
id INT AUTO_INCREMENT NOT NULL COMMENT \'Internal ID\',
gender_id VARCHAR(1) NOT NULL COMMENT \'Internal gender ID\',
private_country_id VARCHAR(2) DEFAULT NULL
COMMENT \'Country code in upper case (ISO 3166-1 Alpha-2)\',
business_country_id VARCHAR(2) NOT NULL COMMENT \'Country code in upper case (ISO 3166-1 Alpha-2)\',
nationality_id VARCHAR(2) NOT NULL COMMENT \'Country code in upper case (ISO 3166-1 Alpha-2)\',
employee_type_id VARCHAR(16) NOT NULL COMMENT \'Internal employee type ID\',
health_insurance_provider_id INT DEFAULT NULL COMMENT \'Internal ID\',
created INT NOT NULL COMMENT \'Entity creation date as UNIX timestamp\',
first_name VARCHAR(225) NOT NULL COMMENT \'First name\',
title VARCHAR(225) DEFAULT NULL COMMENT \'Optional title\',
last_name VARCHAR(225) NOT NULL COMMENT \'Last name\',
email VARCHAR(254) DEFAULT NULL COMMENT \'Optional e-mail address\',
private_phone VARCHAR(225) DEFAULT NULL COMMENT \'Optional private phone number\',
business_phone VARCHAR(225) DEFAULT NULL COMMENT \'Optional business phone number\',
id_external VARCHAR(225) DEFAULT NULL COMMENT \'Optional external ID\',
private_address VARCHAR(225) DEFAULT NULL COMMENT \'Optional private postal address for employee\',
business_address VARCHAR(225) NOT NULL COMMENT \'Business postal address for employee\',
private_zip_code VARCHAR(16) DEFAULT NULL
COMMENT \'Optional private zip code of address for employee\',
business_zip_code VARCHAR(16) NOT NULL COMMENT \'Business zip code of address for employee\',
private_city VARCHAR(225) DEFAULT NULL COMMENT \'Optional private city of address for employee\',
business_city VARCHAR(225) NOT NULL COMMENT \'Optional business city of address for employee\',
birthday DATE NOT NULL COMMENT \'Birthday\',
job_title VARCHAR(225) NOT NULL COMMENT \'Job title\',
job_entry_date DATE NOT NULL COMMENT \'Job entry date\',
org_unit_id INT NOT NULL COMMENT \'Internal ID\',
active SMALLINT DEFAULT 1 NOT NULL COMMENT \'Indicator if entity is active\',
last_active_date DATE DEFAULT NULL COMMENT \'Last active date\',
INDEX IDX_5D9F75A1708A0E0 (gender_id),
INDEX IDX_5D9F75A1F4EA9407 (private_country_id),
INDEX IDX_5D9F75A1398C36DB (business_country_id),
INDEX IDX_5D9F75A11C9DA55 (nationality_id),
INDEX IDX_5D9F75A14500DA9C (employee_type_id),
INDEX IDX_5D9F75A19CADC2E8 (health_insurance_provider_id),
INDEX IDX_5D9F75A18BC224C3 (org_unit_id),
UNIQUE INDEX UNIQ_5D9F75A1E7927C74 (email),
PRIMARY KEY(id)
) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB
'
);
$this->addSql(
'
CREATE TABLE org_unit (
id INT AUTO_INCREMENT NOT NULL COMMENT \'Internal ID\',
created INT NOT NULL COMMENT \'Entity creation date as UNIX timestamp\',
name VARCHAR(225) NOT NULL COMMENT \'Name for organizational unit\',
id_external VARCHAR(225) DEFAULT NULL COMMENT \'Optional external ID for organizational unit\',
cost_center VARCHAR(225) DEFAULT NULL COMMENT \'Optional cost center for organizational unit\',
active SMALLINT DEFAULT 1 NOT NULL COMMENT \'Indicator if entity is active\',
parent_id INT DEFAULT NULL COMMENT \'Internal ID\',
first_manager_id INT DEFAULT NULL COMMENT \'Internal ID\',
second_manager_id INT DEFAULT NULL COMMENT \'Internal ID\',
last_active_date DATE DEFAULT NULL COMMENT \'Last active date\',
INDEX IDX_455318CB727ACA70 (parent_id),
INDEX IDX_455318CBE9A65564 (first_manager_id),
INDEX IDX_455318CB9B60D4F0 (second_manager_id),
PRIMARY KEY(id)
) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB
'
);
$this->addSql(
'
ALTER TABLE employee ADD CONSTRAINT FK_5D9F75A1708A0E0 FOREIGN KEY
(gender_id) REFERENCES gender (id)
'
);
$this->addSql(
'
ALTER TABLE employee ADD CONSTRAINT FK_5D9F75A1F92F3E70 FOREIGN KEY
(private_country_id) REFERENCES country (id)
'
);
$this->addSql(
'
ALTER TABLE employee ADD CONSTRAINT FK_5D9F75A1398C36DB FOREIGN KEY
(business_country_id) REFERENCES country (id)
'
);
$this->addSql(
'
ALTER TABLE employee ADD CONSTRAINT FK_5D9F75A11C9DA55 FOREIGN KEY
(nationality_id) REFERENCES country (id)
'
);
$this->addSql(
'
ALTER TABLE employee ADD CONSTRAINT FK_5D9F75A14500DA9C FOREIGN KEY
(employee_type_id) REFERENCES employee_type (id)
'
);
$this->addSql(
'
ALTER TABLE employee ADD CONSTRAINT FK_5D9F75A19CADC2E8 FOREIGN KEY
(health_insurance_provider_id) REFERENCES health_insurance_provider (id)
'
);
$this->addSql(
'
ALTER TABLE employee ADD CONSTRAINT FK_5D9F75A18BC224C3 FOREIGN KEY
(org_unit_id) REFERENCES org_unit (id)
'
);
$this->addSql(
'
ALTER TABLE org_unit ADD CONSTRAINT FK_455318CB727ACA70 FOREIGN KEY
(parent_id) REFERENCES org_unit (id) ON DELETE SET NULL
'
);
$this->addSql(
'
ALTER TABLE org_unit ADD CONSTRAINT FK_455318CBE9A65564 FOREIGN KEY
(first_manager_id) REFERENCES employee (id) ON DELETE SET NULL
'
);
$this->addSql(
'
ALTER TABLE org_unit ADD CONSTRAINT FK_455318CB9B60D4F0 FOREIGN KEY
(second_manager_id) REFERENCES employee (id) ON DELETE SET NULL
'
);
}
}