<?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 Version20211118142717 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('ALTER TABLE tchat_message DROP FOREIGN KEY FK_F45F6AE99AC0396');
        $this->addSql('ALTER TABLE tchat_participant DROP FOREIGN KEY FK_DA05CFDD9AC0396');
        $this->addSql('ALTER TABLE tchat_conversation DROP FOREIGN KEY FK_185132D6C54C8C93');
        $this->addSql('CREATE TABLE tchat_groupe (id INT AUTO_INCREMENT NOT NULL, last_message_id INT DEFAULT NULL, type_id INT NOT NULL, UNIQUE INDEX UNIQ_547B7608BA0E79C3 (last_message_id), INDEX IDX_547B7608C54C8C93 (type_id), INDEX last_message_id_index (last_message_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('CREATE TABLE tchat_groupe_type (id INT AUTO_INCREMENT NOT NULL, libelle VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('CREATE TABLE tchat_groupe_utilisateur (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, groupe_id INT DEFAULT NULL, INDEX IDX_722D5116A76ED395 (user_id), INDEX IDX_722D51167A45358C (groupe_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('ALTER TABLE tchat_groupe ADD CONSTRAINT FK_547B7608BA0E79C3 FOREIGN KEY (last_message_id) REFERENCES tchat_message (id)');
        $this->addSql('ALTER TABLE tchat_groupe ADD CONSTRAINT FK_547B7608C54C8C93 FOREIGN KEY (type_id) REFERENCES tchat_groupe_type (id)');
        $this->addSql('ALTER TABLE tchat_groupe_utilisateur ADD CONSTRAINT FK_722D5116A76ED395 FOREIGN KEY (user_id) REFERENCES symfony_demo_user (id)');
        $this->addSql('ALTER TABLE tchat_groupe_utilisateur ADD CONSTRAINT FK_722D51167A45358C FOREIGN KEY (groupe_id) REFERENCES tchat_groupe (id)');
        $this->addSql('DROP TABLE tchat_conversation');
        $this->addSql('DROP TABLE tchat_conversation_type');
        $this->addSql('DROP TABLE tchat_participant');
        $this->addSql('DROP INDEX IDX_F45F6AE99AC0396 ON tchat_message');
        $this->addSql('ALTER TABLE tchat_message CHANGE conversation_id groupe_id INT DEFAULT NULL');
        $this->addSql('ALTER TABLE tchat_message ADD CONSTRAINT FK_F45F6AE97A45358C FOREIGN KEY (groupe_id) REFERENCES tchat_groupe (id)');
        $this->addSql('CREATE INDEX IDX_F45F6AE97A45358C ON tchat_message (groupe_id)');
        $this->addSql('ALTER TABLE user_filter CHANGE filtre filtre VARCHAR(255) DEFAULT NULL');
    }

    public function down(Schema $schema): void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE tchat_groupe_utilisateur DROP FOREIGN KEY FK_722D51167A45358C');
        $this->addSql('ALTER TABLE tchat_message DROP FOREIGN KEY FK_F45F6AE97A45358C');
        $this->addSql('ALTER TABLE tchat_groupe DROP FOREIGN KEY FK_547B7608C54C8C93');
        $this->addSql('CREATE TABLE tchat_conversation (id INT AUTO_INCREMENT NOT NULL, last_message_id INT DEFAULT NULL, type_id INT NOT NULL, INDEX last_message_id_index (last_message_id), UNIQUE INDEX UNIQ_185132D6BA0E79C3 (last_message_id), INDEX IDX_185132D6C54C8C93 (type_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
        $this->addSql('CREATE TABLE tchat_conversation_type (id INT AUTO_INCREMENT NOT NULL, libelle VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
        $this->addSql('CREATE TABLE tchat_participant (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, conversation_id INT DEFAULT NULL, INDEX IDX_DA05CFDD9AC0396 (conversation_id), INDEX IDX_DA05CFDDA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
        $this->addSql('ALTER TABLE tchat_conversation ADD CONSTRAINT FK_185132D6BA0E79C3 FOREIGN KEY (last_message_id) REFERENCES tchat_message (id)');
        $this->addSql('ALTER TABLE tchat_conversation ADD CONSTRAINT FK_185132D6C54C8C93 FOREIGN KEY (type_id) REFERENCES tchat_conversation_type (id)');
        $this->addSql('ALTER TABLE tchat_participant ADD CONSTRAINT FK_DA05CFDD9AC0396 FOREIGN KEY (conversation_id) REFERENCES tchat_conversation (id)');
        $this->addSql('ALTER TABLE tchat_participant ADD CONSTRAINT FK_DA05CFDDA76ED395 FOREIGN KEY (user_id) REFERENCES symfony_demo_user (id)');
        $this->addSql('DROP TABLE tchat_groupe');
        $this->addSql('DROP TABLE tchat_groupe_type');
        $this->addSql('DROP TABLE tchat_groupe_utilisateur');
        $this->addSql('DROP INDEX IDX_F45F6AE97A45358C ON tchat_message');
        $this->addSql('ALTER TABLE tchat_message CHANGE groupe_id conversation_id INT DEFAULT NULL');
        $this->addSql('ALTER TABLE tchat_message ADD CONSTRAINT FK_F45F6AE99AC0396 FOREIGN KEY (conversation_id) REFERENCES tchat_conversation (id)');
        $this->addSql('CREATE INDEX IDX_F45F6AE99AC0396 ON tchat_message (conversation_id)');
        $this->addSql('ALTER TABLE user_filter CHANGE filtre filtre TEXT CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`');
    }
}
