migrations/Version20220718134633.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 Version20220718134633 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 employee DROP FOREIGN KEY FK_5D9F75A1708A0E0');
  19.         $this->addSql('ALTER TABLE employee DROP FOREIGN KEY FK_5D9F75A1F92F3E70');
  20.         $this->addSql('ALTER TABLE employee DROP FOREIGN KEY FK_5D9F75A1398C36DB');
  21.         $this->addSql('ALTER TABLE employee DROP FOREIGN KEY FK_5D9F75A11C9DA55');
  22.         $this->addSql('ALTER TABLE employee DROP FOREIGN KEY FK_5D9F75A14500DA9C');
  23.         $this->addSql('ALTER TABLE employee DROP FOREIGN KEY FK_5D9F75A19CADC2E8');
  24.         $this->addSql('ALTER TABLE employee DROP FOREIGN KEY FK_5D9F75A18BC224C3');
  25.         $this->addSql('ALTER TABLE org_unit DROP FOREIGN KEY FK_455318CB727ACA70');
  26.         $this->addSql('ALTER TABLE org_unit DROP FOREIGN KEY FK_455318CBE9A65564');
  27.         $this->addSql('ALTER TABLE org_unit DROP FOREIGN KEY FK_455318CB9B60D4F0');
  28.         $this->addSql('DROP TABLE employee');
  29.         $this->addSql('DROP TABLE org_unit');
  30.     }
  31.     public function getDescription(): string
  32.     {
  33.         return
  34.             "- Introduces employee table\n" .
  35.             "- Introduces org_unit table";
  36.     }
  37.     public function up(Schema $schema): void
  38.     {
  39.         // this up() migration is auto-generated, please modify it to your needs
  40.         $this->addSql(
  41.             '
  42.                 CREATE TABLE employee (
  43.                     id INT AUTO_INCREMENT NOT NULL COMMENT \'Internal ID\',
  44.                     gender_id VARCHAR(1) NOT NULL COMMENT \'Internal gender ID\',
  45.                     private_country_id VARCHAR(2) DEFAULT NULL
  46.                         COMMENT \'Country code in upper case (ISO 3166-1 Alpha-2)\',
  47.                     business_country_id VARCHAR(2) NOT NULL COMMENT \'Country code in upper case (ISO 3166-1 Alpha-2)\',
  48.                     nationality_id VARCHAR(2) NOT NULL COMMENT \'Country code in upper case (ISO 3166-1 Alpha-2)\',
  49.                     employee_type_id VARCHAR(16) NOT NULL COMMENT \'Internal employee type ID\',
  50.                     health_insurance_provider_id INT DEFAULT NULL COMMENT \'Internal ID\',
  51.                     created INT NOT NULL COMMENT \'Entity creation date as UNIX timestamp\',
  52.                     first_name VARCHAR(225) NOT NULL COMMENT \'First name\',
  53.                     title VARCHAR(225) DEFAULT NULL COMMENT \'Optional title\',
  54.                     last_name VARCHAR(225) NOT NULL COMMENT \'Last name\',
  55.                     email VARCHAR(254) DEFAULT NULL COMMENT \'Optional e-mail address\',
  56.                     private_phone VARCHAR(225) DEFAULT NULL COMMENT \'Optional private phone number\',
  57.                     business_phone VARCHAR(225) DEFAULT NULL COMMENT \'Optional business phone number\',
  58.                     id_external VARCHAR(225) DEFAULT NULL COMMENT \'Optional external ID\',
  59.                     private_address VARCHAR(225) DEFAULT NULL COMMENT \'Optional private postal address for employee\',
  60.                     business_address VARCHAR(225) NOT NULL COMMENT \'Business postal address for employee\',
  61.                     private_zip_code VARCHAR(16) DEFAULT NULL
  62.                         COMMENT \'Optional private zip code of address for employee\',
  63.                     business_zip_code VARCHAR(16) NOT NULL COMMENT \'Business zip code of address for employee\',
  64.                     private_city VARCHAR(225) DEFAULT NULL COMMENT \'Optional private city of address for employee\',
  65.                     business_city VARCHAR(225) NOT NULL COMMENT \'Optional business city of address for employee\',
  66.                     birthday DATE NOT NULL COMMENT \'Birthday\',
  67.                     job_title VARCHAR(225) NOT NULL COMMENT \'Job title\',
  68.                     job_entry_date DATE NOT NULL COMMENT \'Job entry date\',
  69.                     org_unit_id INT NOT NULL COMMENT \'Internal ID\',
  70.                     active SMALLINT DEFAULT 1 NOT NULL COMMENT \'Indicator if entity is active\',
  71.                     last_active_date DATE DEFAULT NULL COMMENT \'Last active date\',
  72.                     INDEX IDX_5D9F75A1708A0E0 (gender_id),
  73.                     INDEX IDX_5D9F75A1F4EA9407 (private_country_id),
  74.                     INDEX IDX_5D9F75A1398C36DB (business_country_id),
  75.                     INDEX IDX_5D9F75A11C9DA55 (nationality_id),
  76.                     INDEX IDX_5D9F75A14500DA9C (employee_type_id),
  77.                     INDEX IDX_5D9F75A19CADC2E8 (health_insurance_provider_id),
  78.                     INDEX IDX_5D9F75A18BC224C3 (org_unit_id),
  79.                     UNIQUE INDEX UNIQ_5D9F75A1E7927C74 (email),
  80.                     PRIMARY KEY(id)
  81.                 ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB
  82.             '
  83.         );
  84.         $this->addSql(
  85.             '
  86.                 CREATE TABLE org_unit (
  87.                     id INT AUTO_INCREMENT NOT NULL COMMENT \'Internal ID\',
  88.                     created INT NOT NULL COMMENT \'Entity creation date as UNIX timestamp\',
  89.                     name VARCHAR(225) NOT NULL COMMENT \'Name for organizational unit\',
  90.                     id_external VARCHAR(225) DEFAULT NULL COMMENT \'Optional external ID for organizational unit\',
  91.                     cost_center VARCHAR(225) DEFAULT NULL COMMENT \'Optional cost center for organizational unit\',
  92.                     active SMALLINT DEFAULT 1 NOT NULL COMMENT \'Indicator if entity is active\',
  93.                     parent_id INT DEFAULT NULL COMMENT \'Internal ID\',
  94.                     first_manager_id INT DEFAULT NULL COMMENT \'Internal ID\',
  95.                     second_manager_id INT DEFAULT NULL COMMENT \'Internal ID\',
  96.                     last_active_date DATE DEFAULT NULL COMMENT \'Last active date\',
  97.                     INDEX IDX_455318CB727ACA70 (parent_id),
  98.                     INDEX IDX_455318CBE9A65564 (first_manager_id),
  99.                     INDEX IDX_455318CB9B60D4F0 (second_manager_id),
  100.                     PRIMARY KEY(id)
  101.                 ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB
  102.             '
  103.         );
  104.         $this->addSql(
  105.             '
  106.                 ALTER TABLE employee ADD CONSTRAINT FK_5D9F75A1708A0E0 FOREIGN KEY
  107.                     (gender_id) REFERENCES gender (id)
  108.             '
  109.         );
  110.         $this->addSql(
  111.             '
  112.                 ALTER TABLE employee ADD CONSTRAINT FK_5D9F75A1F92F3E70 FOREIGN KEY
  113.                     (private_country_id) REFERENCES country (id)
  114.             '
  115.         );
  116.         $this->addSql(
  117.             '
  118.                 ALTER TABLE employee ADD CONSTRAINT FK_5D9F75A1398C36DB FOREIGN KEY
  119.                     (business_country_id) REFERENCES country (id)
  120.             '
  121.         );
  122.         $this->addSql(
  123.             '
  124.                 ALTER TABLE employee ADD CONSTRAINT FK_5D9F75A11C9DA55 FOREIGN KEY
  125.                     (nationality_id) REFERENCES country (id)
  126.             '
  127.         );
  128.         $this->addSql(
  129.             '
  130.                 ALTER TABLE employee ADD CONSTRAINT FK_5D9F75A14500DA9C FOREIGN KEY
  131.                     (employee_type_id) REFERENCES employee_type (id)
  132.             '
  133.         );
  134.         $this->addSql(
  135.             '
  136.                 ALTER TABLE employee ADD CONSTRAINT FK_5D9F75A19CADC2E8 FOREIGN KEY
  137.                     (health_insurance_provider_id) REFERENCES health_insurance_provider (id)
  138.             '
  139.         );
  140.         $this->addSql(
  141.             '
  142.                 ALTER TABLE employee ADD CONSTRAINT FK_5D9F75A18BC224C3 FOREIGN KEY
  143.                     (org_unit_id) REFERENCES org_unit (id)
  144.             '
  145.         );
  146.         $this->addSql(
  147.             '
  148.                 ALTER TABLE org_unit ADD CONSTRAINT FK_455318CB727ACA70 FOREIGN KEY
  149.                     (parent_id) REFERENCES org_unit (id) ON DELETE SET NULL
  150.             '
  151.         );
  152.         $this->addSql(
  153.             '
  154.                 ALTER TABLE org_unit ADD CONSTRAINT FK_455318CBE9A65564 FOREIGN KEY
  155.                     (first_manager_id) REFERENCES employee (id) ON DELETE SET NULL
  156.             '
  157.         );
  158.         $this->addSql(
  159.             '
  160.                 ALTER TABLE org_unit ADD CONSTRAINT FK_455318CB9B60D4F0 FOREIGN KEY
  161.                     (second_manager_id) REFERENCES employee (id) ON DELETE SET NULL
  162.             '
  163.         );
  164.     }
  165. }