<?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 Version20210713123646 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('CREATE SEQUENCE invoice_chat_channel_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE invoice_chat_channel (id INT NOT NULL, name VARCHAR(255) NOT NULL, widget_id VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE UNIQUE INDEX UNIQ_51306D5AFBE885E2 ON invoice_chat_channel (widget_id)');
$this->addSql('INSERT INTO invoice_chat_channel (id, name, widget_id) VALUES (1,\'Default\', \'default\')');
$this->addSql('ALTER TABLE invoices_chats ADD channel_id INT NOT NULL DEFAULT 1');
$this->addSql('ALTER TABLE invoices_chats ADD CONSTRAINT FK_147B3A2872F5A1AA FOREIGN KEY (channel_id) REFERENCES invoice_chat_channel (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX IDX_147B3A2872F5A1AA ON invoices_chats (channel_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE "invoices_chats" DROP CONSTRAINT FK_147B3A2872F5A1AA');
$this->addSql('DROP SEQUENCE invoice_chat_channel_id_seq CASCADE');
$this->addSql('DROP TABLE invoice_chat_channel');
$this->addSql('DROP INDEX IDX_147B3A2872F5A1AA');
$this->addSql('ALTER TABLE "invoices_chats" DROP channel_id');
}
}