migrations/2021/02/Version20210212095914.php line 1

  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. final class Version20210212095914 extends AbstractMigration
  7. {
  8.     public function up(Schema $schema): void
  9.     {
  10.         $this->addSql('ALTER TABLE contact_employment_relationship DROP FOREIGN KEY FK_EEB3381341CD9E7A');
  11.         $this->addSql('ALTER TABLE contact_employment_relationship DROP FOREIGN KEY FK_EEB338138C03F15C');
  12.         $this->addSql('ALTER TABLE contact_employment_relationship ADD start_date DATE DEFAULT NULL COMMENT \'(DC2Type:date_immutable)\', ADD end_date DATE DEFAULT NULL COMMENT \'(DC2Type:date_immutable)\', CHANGE id id BINARY(16) NOT NULL COMMENT \'(DC2Type:contact_relationship_employment_id)\'');
  13.         $this->addSql('DROP INDEX contact_employment_relationship_unique ON contact_employment_relationship');
  14.         $this->addSql('CREATE UNIQUE INDEX contact_relationship_employment_unique ON contact_employment_relationship (employer_id, employee_id)');
  15.         $this->addSql('ALTER TABLE contact_employment_relationship ADD CONSTRAINT FK_689CF2FE41CD9E7A FOREIGN KEY (employer_id) REFERENCES contact (id)');
  16.         $this->addSql('ALTER TABLE contact_employment_relationship ADD CONSTRAINT FK_689CF2FE8C03F15C FOREIGN KEY (employee_id) REFERENCES contact (id)');
  17.         $this->addSql('ALTER TABLE contact_employment_relationship DROP FOREIGN KEY FK_689CF2FE41CD9E7A');
  18.         $this->addSql('ALTER TABLE contact_employment_relationship DROP FOREIGN KEY FK_689CF2FE8C03F15C');
  19.         $this->addSql('DROP INDEX idx_eeb3381341cd9e7a ON contact_employment_relationship');
  20.         $this->addSql('CREATE INDEX IDX_689CF2FE41CD9E7A ON contact_employment_relationship (employer_id)');
  21.         $this->addSql('DROP INDEX idx_eeb338138c03f15c ON contact_employment_relationship');
  22.         $this->addSql('CREATE INDEX IDX_689CF2FE8C03F15C ON contact_employment_relationship (employee_id)');
  23.         $this->addSql('ALTER TABLE contact_employment_relationship ADD CONSTRAINT FK_689CF2FE41CD9E7A FOREIGN KEY (employer_id) REFERENCES contact (id)');
  24.         $this->addSql('ALTER TABLE contact_employment_relationship ADD CONSTRAINT FK_689CF2FE8C03F15C FOREIGN KEY (employee_id) REFERENCES contact (id)');
  25.         $this->addSql('RENAME TABLE contact_employment_relationship TO contact_relationship_employment');
  26.     }
  27.     public function down(Schema $schema): void
  28.     {
  29.         $this->addSql('RENAME TABLE contact_relationship_employment TO contact_employment_relationship');
  30.         $this->addSql('ALTER TABLE contact_employment_relationship DROP FOREIGN KEY FK_689CF2FE41CD9E7A');
  31.         $this->addSql('ALTER TABLE contact_employment_relationship DROP FOREIGN KEY FK_689CF2FE8C03F15C');
  32.         $this->addSql('ALTER TABLE contact_employment_relationship DROP start_date, DROP end_date, CHANGE id id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid_binary_ordered_time)\'');
  33.         $this->addSql('DROP INDEX contact_relationship_employment_unique ON contact_employment_relationship');
  34.         $this->addSql('CREATE UNIQUE INDEX contact_employment_relationship_unique ON contact_employment_relationship (employer_id, employee_id)');
  35.         $this->addSql('ALTER TABLE contact_employment_relationship ADD CONSTRAINT FK_EEB3381341CD9E7A FOREIGN KEY (employer_id) REFERENCES contact (id)');
  36.         $this->addSql('ALTER TABLE contact_employment_relationship ADD CONSTRAINT FK_EEB338138C03F15C FOREIGN KEY (employee_id) REFERENCES contact (id)');
  37.         $this->addSql('ALTER TABLE contact_employment_relationship DROP FOREIGN KEY FK_689CF2FE41CD9E7A');
  38.         $this->addSql('ALTER TABLE contact_employment_relationship DROP FOREIGN KEY FK_689CF2FE8C03F15C');
  39.         $this->addSql('DROP INDEX idx_689cf2fe41cd9e7a ON contact_employment_relationship');
  40.         $this->addSql('CREATE INDEX IDX_EEB3381341CD9E7A ON contact_employment_relationship (employer_id)');
  41.         $this->addSql('DROP INDEX idx_689cf2fe8c03f15c ON contact_employment_relationship');
  42.         $this->addSql('CREATE INDEX IDX_EEB338138C03F15C ON contact_employment_relationship (employee_id)');
  43.         $this->addSql('ALTER TABLE contact_employment_relationship ADD CONSTRAINT FK_689CF2FE41CD9E7A FOREIGN KEY (employer_id) REFERENCES contact (id)');
  44.         $this->addSql('ALTER TABLE contact_employment_relationship ADD CONSTRAINT FK_689CF2FE8C03F15C FOREIGN KEY (employee_id) REFERENCES contact (id)');
  45.     }
  46. }