<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20221026121950 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE call.call ALTER is_working_time DROP DEFAULT');
$this->addSql('ALTER TABLE call.call ALTER is_working_time DROP NOT NULL');
$this->addSql('ALTER TABLE freeswitch.ivr ADD non_working_time_attachment_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE freeswitch.ivr ADD prospect_work_schedule_id INT DEFAULT NULL');
$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');
$this->addSql('CREATE INDEX IDX_57E62D60B019F68E ON freeswitch.ivr (non_working_time_attachment_id)');
// Migrate data from account.tenant to freeswitch.ivr
$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');
$this->addSql('ALTER TABLE account.tenant DROP CONSTRAINT fk_2372d18eb019f68e');
$this->addSql('DROP INDEX account.idx_2372d18eb019f68e');
$this->addSql('ALTER TABLE account.tenant DROP non_working_time_attachment_id');
$this->addSql('ALTER TABLE account.tenant DROP prospect_work_schedule_id');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE call.call ALTER is_working_time SET DEFAULT true');
$this->addSql('ALTER TABLE call.call ALTER is_working_time SET NOT NULL');
$this->addSql('ALTER TABLE account.tenant ADD non_working_time_attachment_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE account.tenant ADD prospect_work_schedule_id INT DEFAULT NULL');
$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');
$this->addSql('CREATE INDEX idx_2372d18eb019f68e ON account.tenant (non_working_time_attachment_id)');
// Migrate data from freeswitch.ivr to account.tenant
$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');
$this->addSql('ALTER TABLE freeswitch.ivr DROP CONSTRAINT FK_57E62D60B019F68E');
$this->addSql('DROP INDEX freeswitch.IDX_57E62D60B019F68E');
$this->addSql('ALTER TABLE freeswitch.ivr DROP non_working_time_attachment_id');
$this->addSql('ALTER TABLE freeswitch.ivr DROP prospect_work_schedule_id');
}
}