<?php

declare(strict_types=1);

namespace DoctrineMigrations\Latest;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
 * Auto-generated Migration: Please modify to your needs!
 */
final class Version20241017141106 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 tables_tables (tables_source INT NOT NULL, tables_target INT NOT NULL, PRIMARY KEY(tables_source, tables_target))');
        $this->addSql('CREATE INDEX IDX_D19ED3B4A53AEE6 ON tables_tables (tables_source)');
        $this->addSql('CREATE INDEX IDX_D19ED3B413B6FE69 ON tables_tables (tables_target)');
        $this->addSql('ALTER TABLE tables_tables ADD CONSTRAINT FK_D19ED3B4A53AEE6 FOREIGN KEY (tables_source) REFERENCES tables (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE tables_tables ADD CONSTRAINT FK_D19ED3B413B6FE69 FOREIGN KEY (tables_target) REFERENCES tables (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE utilisateurs DROP CONSTRAINT fk_497b315e4de1870d');
        $this->addSql('DROP INDEX idx_497b315e4de1870d');
        $this->addSql('ALTER TABLE utilisateurs DROP tabl_id');
    }

    public function down(Schema $schema): void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('CREATE SCHEMA public');
        $this->addSql('ALTER TABLE tables_tables DROP CONSTRAINT FK_D19ED3B4A53AEE6');
        $this->addSql('ALTER TABLE tables_tables DROP CONSTRAINT FK_D19ED3B413B6FE69');
        $this->addSql('DROP TABLE tables_tables');
        $this->addSql('ALTER TABLE utilisateurs ADD tabl_id INT DEFAULT NULL');
        $this->addSql('ALTER TABLE utilisateurs ADD CONSTRAINT fk_497b315e4de1870d FOREIGN KEY (tabl_id) REFERENCES tables (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('CREATE INDEX idx_497b315e4de1870d ON utilisateurs (tabl_id)');
    }
}