<?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 Version20240206072303 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('DROP INDEX uniq_51306d5afbe885e2');
$this->addSql('ALTER TABLE invoice_chat_channel RENAME COLUMN widget_id TO external_id');
$this->addSql('ALTER TABLE invoice_chat_channel ADD external_type VARCHAR(255)');
$this->addSql("UPDATE invoice_chat_channel SET external_type='jivo'");
$this->addSql('ALTER TABLE invoice_chat_channel ALTER COLUMN external_type SET NOT NULL');
$this->addSql('CREATE INDEX chat_channel_unique_external_idx ON invoice_chat_channel (external_id, external_type)');
$this->addSql('DROP INDEX uniq_147b3a284bee512d');
$this->addSql('ALTER TABLE invoices_chats RENAME COLUMN outer_id TO external_id');
$this->addSql('ALTER TABLE invoices_chats ALTER COLUMN external_id type VARCHAR(255)');
$this->addSql('CREATE INDEX invoice_chat_unique_external_idx ON invoices_chats (external_id, channel_id)');
$this->addSql('ALTER TABLE invoices_chats_visitors RENAME COLUMN number TO external_id');
$this->addSql('ALTER TABLE invoices_chats_visitors ALTER COLUMN external_id type VARCHAR(255)');
$this->addSql('ALTER TABLE invoices_chats_visitors ADD external_type VARCHAR(255)');
$this->addSql("UPDATE invoices_chats_visitors SET external_type='jivo'");
$this->addSql('ALTER TABLE invoices_chats_visitors ALTER COLUMN external_type SET NOT NULL');
$this->addSql('ALTER TABLE invoices_chats_visitors DROP description');
$this->addSql('CREATE INDEX chat_visitor_unique_external_idx ON invoices_chats_visitors (external_id, external_type)');
$this->addSql('CREATE EXTENSION IF NOT EXISTS "uuid-ossp";');
$this->addSql('ALTER TABLE salary_period ALTER fix_rate SET DEFAULT 20');
$this->addSql('ALTER TABLE users ADD token UUID NOT NULL DEFAULT uuid_generate_v4()');
$this->addSql('CREATE UNIQUE INDEX UNIQ_1483A5E95F37A13B ON users (token)');
// $this->addSql('ALTER TABLE users ALTER token TYPE UUID');
// $this->addSql('ALTER TABLE users ALTER token DROP DEFAULT');
// $this->addSql('COMMENT ON COLUMN users.token IS \'(DC2Type:uuid)\'');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP INDEX UNIQ_1483A5E95F37A13B');
$this->addSql('ALTER TABLE "users" DROP token');
$this->addSql('ALTER TABLE salary_period ALTER fix_rate SET DEFAULT 15');
$this->addSql('DROP INDEX chat_channel_unique_external_idx');
$this->addSql('ALTER TABLE invoice_chat_channel RENAME COLUMN external_id TO widget_id');
$this->addSql('CREATE UNIQUE INDEX uniq_51306d5afbe885e2 ON invoice_chat_channel (widget_id)');
$this->addSql('DROP INDEX chat_visitor_unique_external_idx');
$this->addSql('ALTER TABLE invoices_chats_visitors RENAME COLUMN external_id TO number');
$this->addSql('ALTER TABLE invoices_chats_visitors ALTER COLUMN type number INT NOT NULL');
$this->addSql('ALTER TABLE "invoices_chats_visitors" ADD description TEXT DEFAULT NULL');
$this->addSql('ALTER TABLE "invoices_chats_visitors" DROP type');
$this->addSql('DROP INDEX invoice_chat_unique_external_idx');
$this->addSql('ALTER TABLE invoices_chats RENAME COLUMN external_id TO outer_id');
$this->addSql('ALTER TABLE invoices_chats ALTER COLUMN outer_id type INT NOT NULL');
$this->addSql('CREATE UNIQUE INDEX uniq_147b3a284bee512d ON "invoices_chats" (outer_id)');
}
}