<?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 Version20210728151600 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 group_right (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 `right` (id INT AUTO_INCREMENT NOT NULL, group_right_id INT NOT NULL, libelle VARCHAR(255) NOT NULL, INDEX IDX_B4CA75145DA7244A (group_right_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('ALTER TABLE `right` ADD CONSTRAINT FK_B4CA75145DA7244A FOREIGN KEY (group_right_id) REFERENCES group_right (id)');
        $this->addSql('ALTER TABLE role ADD rights JSON DEFAULT NULL');
        $this->addSql('ALTER TABLE symfony_demo_user ADD rights JSON DEFAULT NULL');
        $this->addSql('CREATE UNIQUE INDEX UNIQ_8FB094A1F85E0677 ON symfony_demo_user (username)');
    }

    public function down(Schema $schema): void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE `right` DROP FOREIGN KEY FK_B4CA75145DA7244A');
        $this->addSql('DROP TABLE group_right');
        $this->addSql('DROP TABLE `right`');
        $this->addSql('ALTER TABLE role DROP rights');
        $this->addSql('DROP INDEX UNIQ_8FB094A1F85E0677 ON symfony_demo_user');
        $this->addSql('ALTER TABLE symfony_demo_user DROP rights');
    }
}
