migrations/Version20221026121950.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. /**
  7.  * Auto-generated Migration: Please modify to your needs!
  8.  */
  9. final class Version20221026121950 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         // this up() migration is auto-generated, please modify it to your needs
  18.         $this->addSql('ALTER TABLE call.call ALTER is_working_time DROP DEFAULT');
  19.         $this->addSql('ALTER TABLE call.call ALTER is_working_time DROP NOT NULL');
  20.         $this->addSql('ALTER TABLE freeswitch.ivr ADD non_working_time_attachment_id INT DEFAULT NULL');
  21.         $this->addSql('ALTER TABLE freeswitch.ivr ADD prospect_work_schedule_id INT DEFAULT NULL');
  22.         $this->addSql('ALTER TABLE freeswitch.ivr ADD CONSTRAINT FK_57E62D60B019F68E FOREIGN KEY (non_working_time_attachment_id) REFERENCES system.attachment (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  23.         $this->addSql('CREATE INDEX IDX_57E62D60B019F68E ON freeswitch.ivr (non_working_time_attachment_id)');
  24.         // Migrate data from account.tenant to freeswitch.ivr
  25.         $this->addSql('UPDATE freeswitch.ivr i SET prospect_work_schedule_id = t.prospect_work_schedule_id, non_working_time_attachment_id = t.non_working_time_attachment_id FROM account.tenant t WHERE t.id = i.tenant_id');
  26.         $this->addSql('ALTER TABLE account.tenant DROP CONSTRAINT fk_2372d18eb019f68e');
  27.         $this->addSql('DROP INDEX account.idx_2372d18eb019f68e');
  28.         $this->addSql('ALTER TABLE account.tenant DROP non_working_time_attachment_id');
  29.         $this->addSql('ALTER TABLE account.tenant DROP prospect_work_schedule_id');
  30.     }
  31.     public function down(Schema $schema): void
  32.     {
  33.         // this down() migration is auto-generated, please modify it to your needs
  34.         $this->addSql('CREATE SCHEMA public');
  35.         $this->addSql('ALTER TABLE call.call ALTER is_working_time SET DEFAULT true');
  36.         $this->addSql('ALTER TABLE call.call ALTER is_working_time SET NOT NULL');
  37.         $this->addSql('ALTER TABLE account.tenant ADD non_working_time_attachment_id INT DEFAULT NULL');
  38.         $this->addSql('ALTER TABLE account.tenant ADD prospect_work_schedule_id INT DEFAULT NULL');
  39.         $this->addSql('ALTER TABLE account.tenant ADD CONSTRAINT fk_2372d18eb019f68e FOREIGN KEY (non_working_time_attachment_id) REFERENCES system.attachment (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  40.         $this->addSql('CREATE INDEX idx_2372d18eb019f68e ON account.tenant (non_working_time_attachment_id)');
  41.         // Migrate data from freeswitch.ivr to account.tenant
  42.         $this->addSql('UPDATE account.tenant t SET prospect_work_schedule_id = i.prospect_work_schedule_id, non_working_time_attachment_id = i.non_working_time_attachment_id FROM freeswitch.ivr i WHERE t.id = i.tenant_id');
  43.         $this->addSql('ALTER TABLE freeswitch.ivr DROP CONSTRAINT FK_57E62D60B019F68E');
  44.         $this->addSql('DROP INDEX freeswitch.IDX_57E62D60B019F68E');
  45.         $this->addSql('ALTER TABLE freeswitch.ivr DROP non_working_time_attachment_id');
  46.         $this->addSql('ALTER TABLE freeswitch.ivr DROP prospect_work_schedule_id');
  47.     }
  48. }