migrations/Version20240206072303.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 Version20240206072303 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('DROP INDEX uniq_51306d5afbe885e2');
  19.         $this->addSql('ALTER TABLE invoice_chat_channel RENAME COLUMN widget_id TO external_id');
  20.         $this->addSql('ALTER TABLE invoice_chat_channel ADD external_type VARCHAR(255)');
  21.         $this->addSql("UPDATE invoice_chat_channel SET external_type='jivo'");
  22.         $this->addSql('ALTER TABLE invoice_chat_channel ALTER COLUMN external_type SET NOT NULL');
  23.         $this->addSql('CREATE INDEX chat_channel_unique_external_idx ON invoice_chat_channel (external_id, external_type)');
  24.         $this->addSql('DROP INDEX uniq_147b3a284bee512d');
  25.         $this->addSql('ALTER TABLE invoices_chats RENAME COLUMN outer_id TO external_id');
  26.         $this->addSql('ALTER TABLE invoices_chats ALTER COLUMN external_id type VARCHAR(255)');
  27.         $this->addSql('CREATE INDEX invoice_chat_unique_external_idx ON invoices_chats (external_id, channel_id)');
  28.         $this->addSql('ALTER TABLE invoices_chats_visitors RENAME COLUMN number TO external_id');
  29.         $this->addSql('ALTER TABLE invoices_chats_visitors ALTER COLUMN external_id type VARCHAR(255)');
  30.         $this->addSql('ALTER TABLE invoices_chats_visitors ADD external_type VARCHAR(255)');
  31.         $this->addSql("UPDATE invoices_chats_visitors SET external_type='jivo'");
  32.         $this->addSql('ALTER TABLE invoices_chats_visitors ALTER COLUMN external_type SET NOT NULL');
  33.         $this->addSql('ALTER TABLE invoices_chats_visitors DROP description');
  34.         $this->addSql('CREATE INDEX chat_visitor_unique_external_idx ON invoices_chats_visitors (external_id, external_type)');
  35.         $this->addSql('CREATE EXTENSION IF NOT EXISTS "uuid-ossp";');
  36.         $this->addSql('ALTER TABLE salary_period ALTER fix_rate SET DEFAULT 20');
  37.         $this->addSql('ALTER TABLE users ADD token UUID NOT NULL DEFAULT uuid_generate_v4()');
  38.         $this->addSql('CREATE UNIQUE INDEX UNIQ_1483A5E95F37A13B ON users (token)');
  39. //        $this->addSql('ALTER TABLE users ALTER token TYPE UUID');
  40. //        $this->addSql('ALTER TABLE users ALTER token DROP DEFAULT');
  41. //        $this->addSql('COMMENT ON COLUMN users.token IS \'(DC2Type:uuid)\'');
  42.     }
  43.     public function down(Schema $schema): void
  44.     {
  45.         // this down() migration is auto-generated, please modify it to your needs
  46.         $this->addSql('DROP INDEX UNIQ_1483A5E95F37A13B');
  47.         $this->addSql('ALTER TABLE "users" DROP token');
  48.         $this->addSql('ALTER TABLE salary_period ALTER fix_rate SET DEFAULT 15');
  49.         $this->addSql('DROP INDEX chat_channel_unique_external_idx');
  50.         $this->addSql('ALTER TABLE invoice_chat_channel RENAME COLUMN external_id TO widget_id');
  51.         $this->addSql('CREATE UNIQUE INDEX uniq_51306d5afbe885e2 ON invoice_chat_channel (widget_id)');
  52.         $this->addSql('DROP INDEX chat_visitor_unique_external_idx');
  53.         $this->addSql('ALTER TABLE invoices_chats_visitors RENAME COLUMN external_id TO number');
  54.         $this->addSql('ALTER TABLE invoices_chats_visitors ALTER COLUMN type number INT NOT NULL');
  55.         $this->addSql('ALTER TABLE "invoices_chats_visitors" ADD description TEXT DEFAULT NULL');
  56.         $this->addSql('ALTER TABLE "invoices_chats_visitors" DROP type');
  57.         $this->addSql('DROP INDEX invoice_chat_unique_external_idx');
  58.         $this->addSql('ALTER TABLE invoices_chats RENAME COLUMN external_id TO outer_id');
  59.         $this->addSql('ALTER TABLE invoices_chats ALTER COLUMN outer_id type INT NOT NULL');
  60.         $this->addSql('CREATE UNIQUE INDEX uniq_147b3a284bee512d ON "invoices_chats" (outer_id)');
  61.     }
  62. }