<?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 Version20231113190736 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 TEMPORARY TABLE __temp__classeur_fractal AS SELECT id, membre_fractal_id, name FROM classeur_fractal');
        $this->addSql('DROP TABLE classeur_fractal');
        $this->addSql('CREATE TABLE classeur_fractal (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, membre_fractal_id INTEGER DEFAULT NULL, name VARCHAR(255) DEFAULT NULL, CONSTRAINT FK_66709D1FBDC18023 FOREIGN KEY (membre_fractal_id) REFERENCES membre_fractal (id) ON UPDATE NO ACTION ON DELETE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE)');
        $this->addSql('INSERT INTO classeur_fractal (id, membre_fractal_id, name) SELECT id, membre_fractal_id, name FROM __temp__classeur_fractal');
        $this->addSql('DROP TABLE __temp__classeur_fractal');
        $this->addSql('CREATE INDEX IDX_66709D1FBDC18023 ON classeur_fractal (membre_fractal_id)');
        $this->addSql('CREATE TEMPORARY TABLE __temp__membre_fractal AS SELECT id, role, pseudo FROM membre_fractal');
        $this->addSql('DROP TABLE membre_fractal');
        $this->addSql('CREATE TABLE membre_fractal (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, role VARCHAR(255) NOT NULL, pseudo VARCHAR(255) NOT NULL)');
        $this->addSql('INSERT INTO membre_fractal (id, role, pseudo) SELECT id, role, pseudo FROM __temp__membre_fractal');
        $this->addSql('DROP TABLE __temp__membre_fractal');
    }

    public function down(Schema $schema): void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('CREATE TEMPORARY TABLE __temp__classeur_fractal AS SELECT id, membre_fractal_id, name FROM classeur_fractal');
        $this->addSql('DROP TABLE classeur_fractal');
        $this->addSql('CREATE TABLE classeur_fractal (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, membre_fractal_id INTEGER DEFAULT NULL, name VARCHAR(255) DEFAULT NULL, CONSTRAINT FK_66709D1FBDC18023 FOREIGN KEY (membre_fractal_id) REFERENCES membre_fractal (id) NOT DEFERRABLE INITIALLY IMMEDIATE)');
        $this->addSql('INSERT INTO classeur_fractal (id, membre_fractal_id, name) SELECT id, membre_fractal_id, name FROM __temp__classeur_fractal');
        $this->addSql('DROP TABLE __temp__classeur_fractal');
        $this->addSql('CREATE UNIQUE INDEX UNIQ_66709D1FBDC18023 ON classeur_fractal (membre_fractal_id)');
        $this->addSql('CREATE TEMPORARY TABLE __temp__membre_fractal AS SELECT id, role, pseudo FROM membre_fractal');
        $this->addSql('DROP TABLE membre_fractal');
        $this->addSql('CREATE TABLE membre_fractal (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, classeurfractal_id INTEGER DEFAULT NULL, role VARCHAR(255) NOT NULL, pseudo VARCHAR(255) NOT NULL, CONSTRAINT FK_5D9834C963BEB4BA FOREIGN KEY (classeurfractal_id) REFERENCES classeur_fractal (id) ON UPDATE NO ACTION ON DELETE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE)');
        $this->addSql('INSERT INTO membre_fractal (id, role, pseudo) SELECT id, role, pseudo FROM __temp__membre_fractal');
        $this->addSql('DROP TABLE __temp__membre_fractal');
        $this->addSql('CREATE UNIQUE INDEX UNIQ_5D9834C963BEB4BA ON membre_fractal (classeurfractal_id)');
    }
}
