<?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 Version20210702101948 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 "countries_id_seq" INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE "invoices_id_seq" INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE "invoices_attashments_id_seq" INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE "invoices_chats_id_seq" INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE "invoices_chats_comments_id_seq" INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE "invoices_chats_messages_id_seq" INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE "invoices_chats_visitors_id_seq" INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE "invoices_comments_attachments_id_seq" INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE "invoices_periods_id_seq" INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE "languages_id_seq" INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE "shifts_id_seq" INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE "users_id_seq" INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE "users_invoices_periods_id_seq" INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE "countries" (id INT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE "invoices" (id INT NOT NULL, owner_id INT DEFAULT NULL, period_id INT DEFAULT NULL, chat_id INT DEFAULT NULL, assigned_manager_id INT DEFAULT NULL, title VARCHAR(255) NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, message TEXT DEFAULT NULL, grade INT DEFAULT NULL, conflicted BOOLEAN NOT NULL, was_conflicted BOOLEAN NOT NULL, needs_attention BOOLEAN NOT NULL, created_auto BOOLEAN NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_6A2F2F957E3C61F9 ON "invoices" (owner_id)');
$this->addSql('CREATE INDEX IDX_6A2F2F95EC8B7ADE ON "invoices" (period_id)');
$this->addSql('CREATE INDEX IDX_6A2F2F951A9A7125 ON "invoices" (chat_id)');
$this->addSql('CREATE INDEX IDX_6A2F2F95409F5712 ON "invoices" (assigned_manager_id)');
$this->addSql('CREATE TABLE users_invoices (invoice_id INT NOT NULL, user_id INT NOT NULL, PRIMARY KEY(invoice_id, user_id))');
$this->addSql('CREATE INDEX IDX_116E044F2989F1FD ON users_invoices (invoice_id)');
$this->addSql('CREATE INDEX IDX_116E044FA76ED395 ON users_invoices (user_id)');
$this->addSql('CREATE TABLE "invoices_attashments" (id INT NOT NULL, invoice_id INT DEFAULT NULL, image VARCHAR(255) DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_E8A4099C2989F1FD ON "invoices_attashments" (invoice_id)');
$this->addSql('CREATE TABLE "invoices_chats" (id INT NOT NULL, visitor_id INT DEFAULT NULL, outer_id INT NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE UNIQUE INDEX UNIQ_147B3A284BEE512D ON "invoices_chats" (outer_id)');
$this->addSql('CREATE INDEX IDX_147B3A2870BEE6D ON "invoices_chats" (visitor_id)');
$this->addSql('CREATE TABLE "invoices_chats_comments" (id INT NOT NULL, invoice_id INT DEFAULT NULL, owner_id INT NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, message TEXT NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_2A5278182989F1FD ON "invoices_chats_comments" (invoice_id)');
$this->addSql('CREATE INDEX IDX_2A5278187E3C61F9 ON "invoices_chats_comments" (owner_id)');
$this->addSql('CREATE TABLE "invoices_chats_messages" (id INT NOT NULL, chat_id INT DEFAULT NULL, agent_id INT DEFAULT NULL, created TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, message VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_AECEF0A41A9A7125 ON "invoices_chats_messages" (chat_id)');
$this->addSql('CREATE INDEX IDX_AECEF0A43414710B ON "invoices_chats_messages" (agent_id)');
$this->addSql('CREATE TABLE "invoices_chats_visitors" (id INT NOT NULL, name VARCHAR(255) DEFAULT NULL, email VARCHAR(255) DEFAULT NULL, phone VARCHAR(255) DEFAULT NULL, number VARCHAR(255) DEFAULT NULL, description TEXT DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE "invoices_comments_attachments" (id INT NOT NULL, invoice_comment_id INT DEFAULT NULL, image VARCHAR(255) DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_17D73D2B1B50D8D ON "invoices_comments_attachments" (invoice_comment_id)');
$this->addSql('CREATE TABLE "invoices_periods" (id INT NOT NULL, year SMALLINT NOT NULL, month SMALLINT NOT NULL, active BOOLEAN NOT NULL, green_percent DOUBLE PRECISION NOT NULL, yellow_percent DOUBLE PRECISION NOT NULL, red_percent DOUBLE PRECISION NOT NULL, need_number INT NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE UNIQUE INDEX invoice_period_unique_idx ON "invoices_periods" (year, month)');
$this->addSql('CREATE TABLE "languages" (id INT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE "shifts" (id INT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE "users" (id INT NOT NULL, shift_id INT DEFAULT NULL, email VARCHAR(180) NOT NULL, roles JSON NOT NULL, password VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, phone VARCHAR(255) DEFAULT NULL, active BOOLEAN NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE UNIQUE INDEX UNIQ_1483A5E9E7927C74 ON "users" (email)');
$this->addSql('CREATE INDEX IDX_1483A5E9BB70BC0E ON "users" (shift_id)');
$this->addSql('CREATE TABLE users_countries (user_id INT NOT NULL, country_id INT NOT NULL, PRIMARY KEY(user_id, country_id))');
$this->addSql('CREATE INDEX IDX_3B1B914CA76ED395 ON users_countries (user_id)');
$this->addSql('CREATE INDEX IDX_3B1B914CF92F3E70 ON users_countries (country_id)');
$this->addSql('CREATE TABLE users_languages (user_id INT NOT NULL, language_id INT NOT NULL, PRIMARY KEY(user_id, language_id))');
$this->addSql('CREATE INDEX IDX_C6AC2998A76ED395 ON users_languages (user_id)');
$this->addSql('CREATE INDEX IDX_C6AC299882F1BAF4 ON users_languages (language_id)');
$this->addSql('CREATE TABLE users_invoices_chats (user_id INT NOT NULL, invoice_chat_id INT NOT NULL, PRIMARY KEY(user_id, invoice_chat_id))');
$this->addSql('CREATE INDEX IDX_6AC3A39DA76ED395 ON users_invoices_chats (user_id)');
$this->addSql('CREATE INDEX IDX_6AC3A39DE84347F6 ON users_invoices_chats (invoice_chat_id)');
$this->addSql('CREATE TABLE "users_invoices_periods" (id INT NOT NULL, user_id INT DEFAULT NULL, invoice_period_id INT DEFAULT NULL, quality_percent DOUBLE PRECISION NOT NULL, dialogs_quantity INT NOT NULL, grade INT NOT NULL, good_dialogs INT NOT NULL, recommendation_dialogs INT NOT NULL, warning_dialogs INT NOT NULL, error_dialogs INT NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_78D35D95A76ED395 ON "users_invoices_periods" (user_id)');
$this->addSql('CREATE INDEX IDX_78D35D9589248B42 ON "users_invoices_periods" (invoice_period_id)');
$this->addSql('ALTER TABLE "invoices" ADD CONSTRAINT FK_6A2F2F957E3C61F9 FOREIGN KEY (owner_id) REFERENCES "users" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE "invoices" ADD CONSTRAINT FK_6A2F2F95EC8B7ADE FOREIGN KEY (period_id) REFERENCES "invoices_periods" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE "invoices" ADD CONSTRAINT FK_6A2F2F951A9A7125 FOREIGN KEY (chat_id) REFERENCES "invoices_chats" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE "invoices" ADD CONSTRAINT FK_6A2F2F95409F5712 FOREIGN KEY (assigned_manager_id) REFERENCES "users" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE users_invoices ADD CONSTRAINT FK_116E044F2989F1FD FOREIGN KEY (invoice_id) REFERENCES "invoices" (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE users_invoices ADD CONSTRAINT FK_116E044FA76ED395 FOREIGN KEY (user_id) REFERENCES "users" (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE "invoices_attashments" ADD CONSTRAINT FK_E8A4099C2989F1FD FOREIGN KEY (invoice_id) REFERENCES "invoices" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE "invoices_chats" ADD CONSTRAINT FK_147B3A2870BEE6D FOREIGN KEY (visitor_id) REFERENCES "invoices_chats_visitors" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE "invoices_chats_comments" ADD CONSTRAINT FK_2A5278182989F1FD FOREIGN KEY (invoice_id) REFERENCES "invoices" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE "invoices_chats_comments" ADD CONSTRAINT FK_2A5278187E3C61F9 FOREIGN KEY (owner_id) REFERENCES "users" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE "invoices_chats_messages" ADD CONSTRAINT FK_AECEF0A41A9A7125 FOREIGN KEY (chat_id) REFERENCES "invoices_chats" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE "invoices_chats_messages" ADD CONSTRAINT FK_AECEF0A43414710B FOREIGN KEY (agent_id) REFERENCES "users" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE "invoices_comments_attachments" ADD CONSTRAINT FK_17D73D2B1B50D8D FOREIGN KEY (invoice_comment_id) REFERENCES "invoices_chats_comments" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE "users" ADD CONSTRAINT FK_1483A5E9BB70BC0E FOREIGN KEY (shift_id) REFERENCES "shifts" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE users_countries ADD CONSTRAINT FK_3B1B914CA76ED395 FOREIGN KEY (user_id) REFERENCES "users" (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE users_countries ADD CONSTRAINT FK_3B1B914CF92F3E70 FOREIGN KEY (country_id) REFERENCES "countries" (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE users_languages ADD CONSTRAINT FK_C6AC2998A76ED395 FOREIGN KEY (user_id) REFERENCES "users" (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE users_languages ADD CONSTRAINT FK_C6AC299882F1BAF4 FOREIGN KEY (language_id) REFERENCES "languages" (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE users_invoices_chats ADD CONSTRAINT FK_6AC3A39DA76ED395 FOREIGN KEY (user_id) REFERENCES "users" (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE users_invoices_chats ADD CONSTRAINT FK_6AC3A39DE84347F6 FOREIGN KEY (invoice_chat_id) REFERENCES "invoices_chats" (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE "users_invoices_periods" ADD CONSTRAINT FK_78D35D95A76ED395 FOREIGN KEY (user_id) REFERENCES "users" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE "users_invoices_periods" ADD CONSTRAINT FK_78D35D9589248B42 FOREIGN KEY (invoice_period_id) REFERENCES "invoices_periods" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
}
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 users_countries DROP CONSTRAINT FK_3B1B914CF92F3E70');
$this->addSql('ALTER TABLE users_invoices DROP CONSTRAINT FK_116E044F2989F1FD');
$this->addSql('ALTER TABLE "invoices_attashments" DROP CONSTRAINT FK_E8A4099C2989F1FD');
$this->addSql('ALTER TABLE "invoices_chats_comments" DROP CONSTRAINT FK_2A5278182989F1FD');
$this->addSql('ALTER TABLE "invoices" DROP CONSTRAINT FK_6A2F2F951A9A7125');
$this->addSql('ALTER TABLE "invoices_chats_messages" DROP CONSTRAINT FK_AECEF0A41A9A7125');
$this->addSql('ALTER TABLE users_invoices_chats DROP CONSTRAINT FK_6AC3A39DE84347F6');
$this->addSql('ALTER TABLE "invoices_comments_attachments" DROP CONSTRAINT FK_17D73D2B1B50D8D');
$this->addSql('ALTER TABLE "invoices_chats" DROP CONSTRAINT FK_147B3A2870BEE6D');
$this->addSql('ALTER TABLE "invoices" DROP CONSTRAINT FK_6A2F2F95EC8B7ADE');
$this->addSql('ALTER TABLE "users_invoices_periods" DROP CONSTRAINT FK_78D35D9589248B42');
$this->addSql('ALTER TABLE users_languages DROP CONSTRAINT FK_C6AC299882F1BAF4');
$this->addSql('ALTER TABLE "users" DROP CONSTRAINT FK_1483A5E9BB70BC0E');
$this->addSql('ALTER TABLE "invoices" DROP CONSTRAINT FK_6A2F2F957E3C61F9');
$this->addSql('ALTER TABLE "invoices" DROP CONSTRAINT FK_6A2F2F95409F5712');
$this->addSql('ALTER TABLE users_invoices DROP CONSTRAINT FK_116E044FA76ED395');
$this->addSql('ALTER TABLE "invoices_chats_comments" DROP CONSTRAINT FK_2A5278187E3C61F9');
$this->addSql('ALTER TABLE "invoices_chats_messages" DROP CONSTRAINT FK_AECEF0A43414710B');
$this->addSql('ALTER TABLE users_countries DROP CONSTRAINT FK_3B1B914CA76ED395');
$this->addSql('ALTER TABLE users_languages DROP CONSTRAINT FK_C6AC2998A76ED395');
$this->addSql('ALTER TABLE users_invoices_chats DROP CONSTRAINT FK_6AC3A39DA76ED395');
$this->addSql('ALTER TABLE "users_invoices_periods" DROP CONSTRAINT FK_78D35D95A76ED395');
$this->addSql('DROP SEQUENCE "countries_id_seq" CASCADE');
$this->addSql('DROP SEQUENCE "invoices_id_seq" CASCADE');
$this->addSql('DROP SEQUENCE "invoices_attashments_id_seq" CASCADE');
$this->addSql('DROP SEQUENCE "invoices_chats_id_seq" CASCADE');
$this->addSql('DROP SEQUENCE "invoices_chats_comments_id_seq" CASCADE');
$this->addSql('DROP SEQUENCE "invoices_chats_messages_id_seq" CASCADE');
$this->addSql('DROP SEQUENCE "invoices_chats_visitors_id_seq" CASCADE');
$this->addSql('DROP SEQUENCE "invoices_comments_attachments_id_seq" CASCADE');
$this->addSql('DROP SEQUENCE "invoices_periods_id_seq" CASCADE');
$this->addSql('DROP SEQUENCE "languages_id_seq" CASCADE');
$this->addSql('DROP SEQUENCE "shifts_id_seq" CASCADE');
$this->addSql('DROP SEQUENCE "users_id_seq" CASCADE');
$this->addSql('DROP SEQUENCE "users_invoices_periods_id_seq" CASCADE');
$this->addSql('DROP TABLE "countries"');
$this->addSql('DROP TABLE "invoices"');
$this->addSql('DROP TABLE users_invoices');
$this->addSql('DROP TABLE "invoices_attashments"');
$this->addSql('DROP TABLE "invoices_chats"');
$this->addSql('DROP TABLE "invoices_chats_comments"');
$this->addSql('DROP TABLE "invoices_chats_messages"');
$this->addSql('DROP TABLE "invoices_chats_visitors"');
$this->addSql('DROP TABLE "invoices_comments_attachments"');
$this->addSql('DROP TABLE "invoices_periods"');
$this->addSql('DROP TABLE "languages"');
$this->addSql('DROP TABLE "shifts"');
$this->addSql('DROP TABLE "users"');
$this->addSql('DROP TABLE users_countries');
$this->addSql('DROP TABLE users_languages');
$this->addSql('DROP TABLE users_invoices_chats');
$this->addSql('DROP TABLE "users_invoices_periods"');
}
}