migrations/Version20210702101948.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 Version20210702101948 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 "countries_id_seq" INCREMENT BY 1 MINVALUE 1 START 1');
  19.         $this->addSql('CREATE SEQUENCE "invoices_id_seq" INCREMENT BY 1 MINVALUE 1 START 1');
  20.         $this->addSql('CREATE SEQUENCE "invoices_attashments_id_seq" INCREMENT BY 1 MINVALUE 1 START 1');
  21.         $this->addSql('CREATE SEQUENCE "invoices_chats_id_seq" INCREMENT BY 1 MINVALUE 1 START 1');
  22.         $this->addSql('CREATE SEQUENCE "invoices_chats_comments_id_seq" INCREMENT BY 1 MINVALUE 1 START 1');
  23.         $this->addSql('CREATE SEQUENCE "invoices_chats_messages_id_seq" INCREMENT BY 1 MINVALUE 1 START 1');
  24.         $this->addSql('CREATE SEQUENCE "invoices_chats_visitors_id_seq" INCREMENT BY 1 MINVALUE 1 START 1');
  25.         $this->addSql('CREATE SEQUENCE "invoices_comments_attachments_id_seq" INCREMENT BY 1 MINVALUE 1 START 1');
  26.         $this->addSql('CREATE SEQUENCE "invoices_periods_id_seq" INCREMENT BY 1 MINVALUE 1 START 1');
  27.         $this->addSql('CREATE SEQUENCE "languages_id_seq" INCREMENT BY 1 MINVALUE 1 START 1');
  28.         $this->addSql('CREATE SEQUENCE "shifts_id_seq" INCREMENT BY 1 MINVALUE 1 START 1');
  29.         $this->addSql('CREATE SEQUENCE "users_id_seq" INCREMENT BY 1 MINVALUE 1 START 1');
  30.         $this->addSql('CREATE SEQUENCE "users_invoices_periods_id_seq" INCREMENT BY 1 MINVALUE 1 START 1');
  31.         $this->addSql('CREATE TABLE "countries" (id INT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
  32.         $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))');
  33.         $this->addSql('CREATE INDEX IDX_6A2F2F957E3C61F9 ON "invoices" (owner_id)');
  34.         $this->addSql('CREATE INDEX IDX_6A2F2F95EC8B7ADE ON "invoices" (period_id)');
  35.         $this->addSql('CREATE INDEX IDX_6A2F2F951A9A7125 ON "invoices" (chat_id)');
  36.         $this->addSql('CREATE INDEX IDX_6A2F2F95409F5712 ON "invoices" (assigned_manager_id)');
  37.         $this->addSql('CREATE TABLE users_invoices (invoice_id INT NOT NULL, user_id INT NOT NULL, PRIMARY KEY(invoice_id, user_id))');
  38.         $this->addSql('CREATE INDEX IDX_116E044F2989F1FD ON users_invoices (invoice_id)');
  39.         $this->addSql('CREATE INDEX IDX_116E044FA76ED395 ON users_invoices (user_id)');
  40.         $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))');
  41.         $this->addSql('CREATE INDEX IDX_E8A4099C2989F1FD ON "invoices_attashments" (invoice_id)');
  42.         $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))');
  43.         $this->addSql('CREATE UNIQUE INDEX UNIQ_147B3A284BEE512D ON "invoices_chats" (outer_id)');
  44.         $this->addSql('CREATE INDEX IDX_147B3A2870BEE6D ON "invoices_chats" (visitor_id)');
  45.         $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))');
  46.         $this->addSql('CREATE INDEX IDX_2A5278182989F1FD ON "invoices_chats_comments" (invoice_id)');
  47.         $this->addSql('CREATE INDEX IDX_2A5278187E3C61F9 ON "invoices_chats_comments" (owner_id)');
  48.         $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))');
  49.         $this->addSql('CREATE INDEX IDX_AECEF0A41A9A7125 ON "invoices_chats_messages" (chat_id)');
  50.         $this->addSql('CREATE INDEX IDX_AECEF0A43414710B ON "invoices_chats_messages" (agent_id)');
  51.         $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))');
  52.         $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))');
  53.         $this->addSql('CREATE INDEX IDX_17D73D2B1B50D8D ON "invoices_comments_attachments" (invoice_comment_id)');
  54.         $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))');
  55.         $this->addSql('CREATE UNIQUE INDEX invoice_period_unique_idx ON "invoices_periods" (year, month)');
  56.         $this->addSql('CREATE TABLE "languages" (id INT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
  57.         $this->addSql('CREATE TABLE "shifts" (id INT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
  58.         $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))');
  59.         $this->addSql('CREATE UNIQUE INDEX UNIQ_1483A5E9E7927C74 ON "users" (email)');
  60.         $this->addSql('CREATE INDEX IDX_1483A5E9BB70BC0E ON "users" (shift_id)');
  61.         $this->addSql('CREATE TABLE users_countries (user_id INT NOT NULL, country_id INT NOT NULL, PRIMARY KEY(user_id, country_id))');
  62.         $this->addSql('CREATE INDEX IDX_3B1B914CA76ED395 ON users_countries (user_id)');
  63.         $this->addSql('CREATE INDEX IDX_3B1B914CF92F3E70 ON users_countries (country_id)');
  64.         $this->addSql('CREATE TABLE users_languages (user_id INT NOT NULL, language_id INT NOT NULL, PRIMARY KEY(user_id, language_id))');
  65.         $this->addSql('CREATE INDEX IDX_C6AC2998A76ED395 ON users_languages (user_id)');
  66.         $this->addSql('CREATE INDEX IDX_C6AC299882F1BAF4 ON users_languages (language_id)');
  67.         $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))');
  68.         $this->addSql('CREATE INDEX IDX_6AC3A39DA76ED395 ON users_invoices_chats (user_id)');
  69.         $this->addSql('CREATE INDEX IDX_6AC3A39DE84347F6 ON users_invoices_chats (invoice_chat_id)');
  70.         $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))');
  71.         $this->addSql('CREATE INDEX IDX_78D35D95A76ED395 ON "users_invoices_periods" (user_id)');
  72.         $this->addSql('CREATE INDEX IDX_78D35D9589248B42 ON "users_invoices_periods" (invoice_period_id)');
  73.         $this->addSql('ALTER TABLE "invoices" ADD CONSTRAINT FK_6A2F2F957E3C61F9 FOREIGN KEY (owner_id) REFERENCES "users" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  74.         $this->addSql('ALTER TABLE "invoices" ADD CONSTRAINT FK_6A2F2F95EC8B7ADE FOREIGN KEY (period_id) REFERENCES "invoices_periods" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  75.         $this->addSql('ALTER TABLE "invoices" ADD CONSTRAINT FK_6A2F2F951A9A7125 FOREIGN KEY (chat_id) REFERENCES "invoices_chats" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  76.         $this->addSql('ALTER TABLE "invoices" ADD CONSTRAINT FK_6A2F2F95409F5712 FOREIGN KEY (assigned_manager_id) REFERENCES "users" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  77.         $this->addSql('ALTER TABLE users_invoices ADD CONSTRAINT FK_116E044F2989F1FD FOREIGN KEY (invoice_id) REFERENCES "invoices" (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
  78.         $this->addSql('ALTER TABLE users_invoices ADD CONSTRAINT FK_116E044FA76ED395 FOREIGN KEY (user_id) REFERENCES "users" (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
  79.         $this->addSql('ALTER TABLE "invoices_attashments" ADD CONSTRAINT FK_E8A4099C2989F1FD FOREIGN KEY (invoice_id) REFERENCES "invoices" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  80.         $this->addSql('ALTER TABLE "invoices_chats" ADD CONSTRAINT FK_147B3A2870BEE6D FOREIGN KEY (visitor_id) REFERENCES "invoices_chats_visitors" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  81.         $this->addSql('ALTER TABLE "invoices_chats_comments" ADD CONSTRAINT FK_2A5278182989F1FD FOREIGN KEY (invoice_id) REFERENCES "invoices" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  82.         $this->addSql('ALTER TABLE "invoices_chats_comments" ADD CONSTRAINT FK_2A5278187E3C61F9 FOREIGN KEY (owner_id) REFERENCES "users" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  83.         $this->addSql('ALTER TABLE "invoices_chats_messages" ADD CONSTRAINT FK_AECEF0A41A9A7125 FOREIGN KEY (chat_id) REFERENCES "invoices_chats" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  84.         $this->addSql('ALTER TABLE "invoices_chats_messages" ADD CONSTRAINT FK_AECEF0A43414710B FOREIGN KEY (agent_id) REFERENCES "users" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  85.         $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');
  86.         $this->addSql('ALTER TABLE "users" ADD CONSTRAINT FK_1483A5E9BB70BC0E FOREIGN KEY (shift_id) REFERENCES "shifts" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  87.         $this->addSql('ALTER TABLE users_countries ADD CONSTRAINT FK_3B1B914CA76ED395 FOREIGN KEY (user_id) REFERENCES "users" (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
  88.         $this->addSql('ALTER TABLE users_countries ADD CONSTRAINT FK_3B1B914CF92F3E70 FOREIGN KEY (country_id) REFERENCES "countries" (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
  89.         $this->addSql('ALTER TABLE users_languages ADD CONSTRAINT FK_C6AC2998A76ED395 FOREIGN KEY (user_id) REFERENCES "users" (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
  90.         $this->addSql('ALTER TABLE users_languages ADD CONSTRAINT FK_C6AC299882F1BAF4 FOREIGN KEY (language_id) REFERENCES "languages" (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
  91.         $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');
  92.         $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');
  93.         $this->addSql('ALTER TABLE "users_invoices_periods" ADD CONSTRAINT FK_78D35D95A76ED395 FOREIGN KEY (user_id) REFERENCES "users" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  94.         $this->addSql('ALTER TABLE "users_invoices_periods" ADD CONSTRAINT FK_78D35D9589248B42 FOREIGN KEY (invoice_period_id) REFERENCES "invoices_periods" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  95.     }
  96.     public function down(Schema $schema): void
  97.     {
  98.         // this down() migration is auto-generated, please modify it to your needs
  99.         $this->addSql('CREATE SCHEMA public');
  100.         $this->addSql('ALTER TABLE users_countries DROP CONSTRAINT FK_3B1B914CF92F3E70');
  101.         $this->addSql('ALTER TABLE users_invoices DROP CONSTRAINT FK_116E044F2989F1FD');
  102.         $this->addSql('ALTER TABLE "invoices_attashments" DROP CONSTRAINT FK_E8A4099C2989F1FD');
  103.         $this->addSql('ALTER TABLE "invoices_chats_comments" DROP CONSTRAINT FK_2A5278182989F1FD');
  104.         $this->addSql('ALTER TABLE "invoices" DROP CONSTRAINT FK_6A2F2F951A9A7125');
  105.         $this->addSql('ALTER TABLE "invoices_chats_messages" DROP CONSTRAINT FK_AECEF0A41A9A7125');
  106.         $this->addSql('ALTER TABLE users_invoices_chats DROP CONSTRAINT FK_6AC3A39DE84347F6');
  107.         $this->addSql('ALTER TABLE "invoices_comments_attachments" DROP CONSTRAINT FK_17D73D2B1B50D8D');
  108.         $this->addSql('ALTER TABLE "invoices_chats" DROP CONSTRAINT FK_147B3A2870BEE6D');
  109.         $this->addSql('ALTER TABLE "invoices" DROP CONSTRAINT FK_6A2F2F95EC8B7ADE');
  110.         $this->addSql('ALTER TABLE "users_invoices_periods" DROP CONSTRAINT FK_78D35D9589248B42');
  111.         $this->addSql('ALTER TABLE users_languages DROP CONSTRAINT FK_C6AC299882F1BAF4');
  112.         $this->addSql('ALTER TABLE "users" DROP CONSTRAINT FK_1483A5E9BB70BC0E');
  113.         $this->addSql('ALTER TABLE "invoices" DROP CONSTRAINT FK_6A2F2F957E3C61F9');
  114.         $this->addSql('ALTER TABLE "invoices" DROP CONSTRAINT FK_6A2F2F95409F5712');
  115.         $this->addSql('ALTER TABLE users_invoices DROP CONSTRAINT FK_116E044FA76ED395');
  116.         $this->addSql('ALTER TABLE "invoices_chats_comments" DROP CONSTRAINT FK_2A5278187E3C61F9');
  117.         $this->addSql('ALTER TABLE "invoices_chats_messages" DROP CONSTRAINT FK_AECEF0A43414710B');
  118.         $this->addSql('ALTER TABLE users_countries DROP CONSTRAINT FK_3B1B914CA76ED395');
  119.         $this->addSql('ALTER TABLE users_languages DROP CONSTRAINT FK_C6AC2998A76ED395');
  120.         $this->addSql('ALTER TABLE users_invoices_chats DROP CONSTRAINT FK_6AC3A39DA76ED395');
  121.         $this->addSql('ALTER TABLE "users_invoices_periods" DROP CONSTRAINT FK_78D35D95A76ED395');
  122.         $this->addSql('DROP SEQUENCE "countries_id_seq" CASCADE');
  123.         $this->addSql('DROP SEQUENCE "invoices_id_seq" CASCADE');
  124.         $this->addSql('DROP SEQUENCE "invoices_attashments_id_seq" CASCADE');
  125.         $this->addSql('DROP SEQUENCE "invoices_chats_id_seq" CASCADE');
  126.         $this->addSql('DROP SEQUENCE "invoices_chats_comments_id_seq" CASCADE');
  127.         $this->addSql('DROP SEQUENCE "invoices_chats_messages_id_seq" CASCADE');
  128.         $this->addSql('DROP SEQUENCE "invoices_chats_visitors_id_seq" CASCADE');
  129.         $this->addSql('DROP SEQUENCE "invoices_comments_attachments_id_seq" CASCADE');
  130.         $this->addSql('DROP SEQUENCE "invoices_periods_id_seq" CASCADE');
  131.         $this->addSql('DROP SEQUENCE "languages_id_seq" CASCADE');
  132.         $this->addSql('DROP SEQUENCE "shifts_id_seq" CASCADE');
  133.         $this->addSql('DROP SEQUENCE "users_id_seq" CASCADE');
  134.         $this->addSql('DROP SEQUENCE "users_invoices_periods_id_seq" CASCADE');
  135.         $this->addSql('DROP TABLE "countries"');
  136.         $this->addSql('DROP TABLE "invoices"');
  137.         $this->addSql('DROP TABLE users_invoices');
  138.         $this->addSql('DROP TABLE "invoices_attashments"');
  139.         $this->addSql('DROP TABLE "invoices_chats"');
  140.         $this->addSql('DROP TABLE "invoices_chats_comments"');
  141.         $this->addSql('DROP TABLE "invoices_chats_messages"');
  142.         $this->addSql('DROP TABLE "invoices_chats_visitors"');
  143.         $this->addSql('DROP TABLE "invoices_comments_attachments"');
  144.         $this->addSql('DROP TABLE "invoices_periods"');
  145.         $this->addSql('DROP TABLE "languages"');
  146.         $this->addSql('DROP TABLE "shifts"');
  147.         $this->addSql('DROP TABLE "users"');
  148.         $this->addSql('DROP TABLE users_countries');
  149.         $this->addSql('DROP TABLE users_languages');
  150.         $this->addSql('DROP TABLE users_invoices_chats');
  151.         $this->addSql('DROP TABLE "users_invoices_periods"');
  152.     }
  153. }