<?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 Version20220223212944 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 omni.contact_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE omni.conversation_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE omni.message_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE omni.message_attachment_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE omni.contact (id INT NOT NULL, channel_id INT NOT NULL, tenant_id INT NOT NULL, name VARCHAR(255) NOT NULL, surname VARCHAR(255) DEFAULT NULL, avatar VARCHAR(255) DEFAULT NULL, identifier TEXT NOT NULL, prospect_contact INT DEFAULT NULL, created_at TIMESTAMP(6) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(6) WITHOUT TIME ZONE NOT NULL, is_deleted BOOLEAN DEFAULT \'false\' NOT NULL, deleted_at TIMESTAMP(6) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_B84FA43772F5A1AA ON omni.contact (channel_id)');
$this->addSql('CREATE INDEX IDX_B84FA4379033212A ON omni.contact (tenant_id)');
$this->addSql('CREATE TABLE omni.conversation (id INT NOT NULL, contact_id INT NOT NULL, channel_id INT NOT NULL, tenant_id INT NOT NULL, status VARCHAR(50) DEFAULT \'open\' NOT NULL, created_at TIMESTAMP(6) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(6) WITHOUT TIME ZONE NOT NULL, is_deleted BOOLEAN DEFAULT \'false\' NOT NULL, deleted_at TIMESTAMP(6) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE UNIQUE INDEX UNIQ_7986D084E7A1254A ON omni.conversation (contact_id)');
$this->addSql('CREATE INDEX IDX_7986D08472F5A1AA ON omni.conversation (channel_id)');
$this->addSql('CREATE INDEX IDX_7986D0849033212A ON omni.conversation (tenant_id)');
$this->addSql('CREATE TABLE omni.message (id INT NOT NULL, conversation_id INT NOT NULL, tenant_id INT NOT NULL, mid TEXT NOT NULL, direction VARCHAR(255) NOT NULL, status VARCHAR(255) NOT NULL, text TEXT DEFAULT NULL, created_at TIMESTAMP(6) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(6) WITHOUT TIME ZONE NOT NULL, is_deleted BOOLEAN DEFAULT \'false\' NOT NULL, deleted_at TIMESTAMP(6) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_429072709AC0396 ON omni.message (conversation_id)');
$this->addSql('CREATE INDEX IDX_429072709033212A ON omni.message (tenant_id)');
$this->addSql('CREATE TABLE omni.message_attachment (id INT NOT NULL, message_id INT NOT NULL, tenant_id INT NOT NULL, type VARCHAR(255) NOT NULL, url VARCHAR(255) NOT NULL, title VARCHAR(255) DEFAULT NULL, created_at TIMESTAMP(6) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(6) WITHOUT TIME ZONE NOT NULL, is_deleted BOOLEAN DEFAULT \'false\' NOT NULL, deleted_at TIMESTAMP(6) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_B7A7A93B537A1329 ON omni.message_attachment (message_id)');
$this->addSql('CREATE INDEX IDX_B7A7A93B9033212A ON omni.message_attachment (tenant_id)');
$this->addSql('ALTER TABLE omni.contact ADD CONSTRAINT FK_B84FA43772F5A1AA FOREIGN KEY (channel_id) REFERENCES omni.channel (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE omni.contact ADD CONSTRAINT FK_B84FA4379033212A FOREIGN KEY (tenant_id) REFERENCES account.tenant (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE omni.conversation ADD CONSTRAINT FK_7986D084E7A1254A FOREIGN KEY (contact_id) REFERENCES omni.contact (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE omni.conversation ADD CONSTRAINT FK_7986D08472F5A1AA FOREIGN KEY (channel_id) REFERENCES omni.channel (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE omni.conversation ADD CONSTRAINT FK_7986D0849033212A FOREIGN KEY (tenant_id) REFERENCES account.tenant (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE omni.message ADD CONSTRAINT FK_429072709AC0396 FOREIGN KEY (conversation_id) REFERENCES omni.conversation (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE omni.message ADD CONSTRAINT FK_429072709033212A FOREIGN KEY (tenant_id) REFERENCES account.tenant (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE omni.message_attachment ADD CONSTRAINT FK_B7A7A93B537A1329 FOREIGN KEY (message_id) REFERENCES omni.message (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE omni.message_attachment ADD CONSTRAINT FK_B7A7A93B9033212A FOREIGN KEY (tenant_id) REFERENCES account.tenant (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE omni.channel ADD identifier TEXT DEFAULT NULL');
}
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 omni.conversation DROP CONSTRAINT FK_7986D084E7A1254A');
$this->addSql('ALTER TABLE omni.message DROP CONSTRAINT FK_429072709AC0396');
$this->addSql('ALTER TABLE omni.message_attachment DROP CONSTRAINT FK_B7A7A93B537A1329');
$this->addSql('DROP SEQUENCE omni.contact_id_seq CASCADE');
$this->addSql('DROP SEQUENCE omni.conversation_id_seq CASCADE');
$this->addSql('DROP SEQUENCE omni.message_id_seq CASCADE');
$this->addSql('DROP SEQUENCE omni.message_attachment_id_seq CASCADE');
$this->addSql('DROP TABLE omni.contact');
$this->addSql('DROP TABLE omni.conversation');
$this->addSql('DROP TABLE omni.message');
$this->addSql('DROP TABLE omni.message_attachment');
$this->addSql('ALTER TABLE omni.channel DROP identifier');
}
}