migrations/Version20220223212944.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 Version20220223212944 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('CREATE SEQUENCE omni.contact_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
  19.         $this->addSql('CREATE SEQUENCE omni.conversation_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
  20.         $this->addSql('CREATE SEQUENCE omni.message_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
  21.         $this->addSql('CREATE SEQUENCE omni.message_attachment_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
  22.         $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))');
  23.         $this->addSql('CREATE INDEX IDX_B84FA43772F5A1AA ON omni.contact (channel_id)');
  24.         $this->addSql('CREATE INDEX IDX_B84FA4379033212A ON omni.contact (tenant_id)');
  25.         $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))');
  26.         $this->addSql('CREATE UNIQUE INDEX UNIQ_7986D084E7A1254A ON omni.conversation (contact_id)');
  27.         $this->addSql('CREATE INDEX IDX_7986D08472F5A1AA ON omni.conversation (channel_id)');
  28.         $this->addSql('CREATE INDEX IDX_7986D0849033212A ON omni.conversation (tenant_id)');
  29.         $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))');
  30.         $this->addSql('CREATE INDEX IDX_429072709AC0396 ON omni.message (conversation_id)');
  31.         $this->addSql('CREATE INDEX IDX_429072709033212A ON omni.message (tenant_id)');
  32.         $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))');
  33.         $this->addSql('CREATE INDEX IDX_B7A7A93B537A1329 ON omni.message_attachment (message_id)');
  34.         $this->addSql('CREATE INDEX IDX_B7A7A93B9033212A ON omni.message_attachment (tenant_id)');
  35.         $this->addSql('ALTER TABLE omni.contact ADD CONSTRAINT FK_B84FA43772F5A1AA FOREIGN KEY (channel_id) REFERENCES omni.channel (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  36.         $this->addSql('ALTER TABLE omni.contact ADD CONSTRAINT FK_B84FA4379033212A FOREIGN KEY (tenant_id) REFERENCES account.tenant (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  37.         $this->addSql('ALTER TABLE omni.conversation ADD CONSTRAINT FK_7986D084E7A1254A FOREIGN KEY (contact_id) REFERENCES omni.contact (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  38.         $this->addSql('ALTER TABLE omni.conversation ADD CONSTRAINT FK_7986D08472F5A1AA FOREIGN KEY (channel_id) REFERENCES omni.channel (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  39.         $this->addSql('ALTER TABLE omni.conversation ADD CONSTRAINT FK_7986D0849033212A FOREIGN KEY (tenant_id) REFERENCES account.tenant (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  40.         $this->addSql('ALTER TABLE omni.message ADD CONSTRAINT FK_429072709AC0396 FOREIGN KEY (conversation_id) REFERENCES omni.conversation (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  41.         $this->addSql('ALTER TABLE omni.message ADD CONSTRAINT FK_429072709033212A FOREIGN KEY (tenant_id) REFERENCES account.tenant (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  42.         $this->addSql('ALTER TABLE omni.message_attachment ADD CONSTRAINT FK_B7A7A93B537A1329 FOREIGN KEY (message_id) REFERENCES omni.message (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  43.         $this->addSql('ALTER TABLE omni.message_attachment ADD CONSTRAINT FK_B7A7A93B9033212A FOREIGN KEY (tenant_id) REFERENCES account.tenant (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  44.         $this->addSql('ALTER TABLE omni.channel ADD identifier TEXT DEFAULT NULL');
  45.     }
  46.     public function down(Schema $schema): void
  47.     {
  48.         // this down() migration is auto-generated, please modify it to your needs
  49.         $this->addSql('CREATE SCHEMA public');
  50.         $this->addSql('ALTER TABLE omni.conversation DROP CONSTRAINT FK_7986D084E7A1254A');
  51.         $this->addSql('ALTER TABLE omni.message DROP CONSTRAINT FK_429072709AC0396');
  52.         $this->addSql('ALTER TABLE omni.message_attachment DROP CONSTRAINT FK_B7A7A93B537A1329');
  53.         $this->addSql('DROP SEQUENCE omni.contact_id_seq CASCADE');
  54.         $this->addSql('DROP SEQUENCE omni.conversation_id_seq CASCADE');
  55.         $this->addSql('DROP SEQUENCE omni.message_id_seq CASCADE');
  56.         $this->addSql('DROP SEQUENCE omni.message_attachment_id_seq CASCADE');
  57.         $this->addSql('DROP TABLE omni.contact');
  58.         $this->addSql('DROP TABLE omni.conversation');
  59.         $this->addSql('DROP TABLE omni.message');
  60.         $this->addSql('DROP TABLE omni.message_attachment');
  61.         $this->addSql('ALTER TABLE omni.channel DROP identifier');
  62.     }
  63. }