<?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 Version20211105134845 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 TABLE pole (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('ALTER TABLE tchat ADD user_sender_id INT NOT NULL, ADD user_receiver_id INT DEFAULT NULL, ADD group_receiver_id INT NOT NULL');
        $this->addSql('ALTER TABLE tchat ADD CONSTRAINT FK_8EA99CA4F6C43E79 FOREIGN KEY (user_sender_id) REFERENCES symfony_demo_user (id)');
        $this->addSql('ALTER TABLE tchat ADD CONSTRAINT FK_8EA99CA464482423 FOREIGN KEY (user_receiver_id) REFERENCES symfony_demo_user (id)');
        $this->addSql('ALTER TABLE tchat ADD CONSTRAINT FK_8EA99CA4E8EBF277 FOREIGN KEY (group_receiver_id) REFERENCES pole (id)');
        $this->addSql('CREATE INDEX IDX_8EA99CA4F6C43E79 ON tchat (user_sender_id)');
        $this->addSql('CREATE INDEX IDX_8EA99CA464482423 ON tchat (user_receiver_id)');
        $this->addSql('CREATE INDEX IDX_8EA99CA4E8EBF277 ON tchat (group_receiver_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 DROP FOREIGN KEY FK_8EA99CA4E8EBF277');
        $this->addSql('DROP TABLE pole');
        $this->addSql('ALTER TABLE tchat DROP FOREIGN KEY FK_8EA99CA4F6C43E79');
        $this->addSql('ALTER TABLE tchat DROP FOREIGN KEY FK_8EA99CA464482423');
        $this->addSql('DROP INDEX IDX_8EA99CA4F6C43E79 ON tchat');
        $this->addSql('DROP INDEX IDX_8EA99CA464482423 ON tchat');
        $this->addSql('DROP INDEX IDX_8EA99CA4E8EBF277 ON tchat');
        $this->addSql('ALTER TABLE tchat DROP user_sender_id, DROP user_receiver_id, DROP group_receiver_id');
        $this->addSql('ALTER TABLE user_filter CHANGE filtre filtre TEXT CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`');
    }
}
