<?php

declare(strict_types=1);

namespace app\migrations;

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

/**
 * Auto-generated Migration: Please modify to your needs!
 */
final class Version20260320225432 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 categorie_publication (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, libelle VARCHAR(50) NOT NULL, PRIMARY KEY (id))');
        $this->addSql('CREATE UNIQUE INDEX UNIQ_70C24170A4D60759 ON categorie_publication (libelle)');
        $this->addSql('CREATE TABLE constitue (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, optionnel BOOLEAN NOT NULL, mod_id INT NOT NULL, modpack_id INT NOT NULL, PRIMARY KEY (id))');
        $this->addSql('CREATE INDEX IDX_AA077561338E21CD ON constitue (mod_id)');
        $this->addSql('CREATE INDEX IDX_AA077561949D6AEB ON constitue (modpack_id)');
        $this->addSql('CREATE UNIQUE INDEX unique_constitue ON constitue (mod_id, modpack_id)');
        $this->addSql('CREATE TABLE illustration (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, uri VARCHAR(255) NOT NULL, publication_id INT NOT NULL, PRIMARY KEY (id))');
        $this->addSql('CREATE UNIQUE INDEX UNIQ_D67B9A42841CB121 ON illustration (uri)');
        $this->addSql('CREATE UNIQUE INDEX UNIQ_D67B9A4238B217A7 ON illustration (publication_id)');
        $this->addSql('CREATE TABLE joueur (id UUID NOT NULL, pseudo VARCHAR(50) NOT NULL, PRIMARY KEY (id))');
        $this->addSql('CREATE TABLE mod (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, nom VARCHAR(50) NOT NULL, version VARCHAR(50) NOT NULL, uri VARCHAR(255) NOT NULL, PRIMARY KEY (id))');
        $this->addSql('CREATE UNIQUE INDEX UNIQ_17F45348841CB121 ON mod (uri)');
        $this->addSql('CREATE UNIQUE INDEX mod_unique ON mod (nom, version)');
        $this->addSql('CREATE TABLE mod_mod (mod_source INT NOT NULL, mod_target INT NOT NULL, PRIMARY KEY (mod_source, mod_target))');
        $this->addSql('CREATE INDEX IDX_99C60BF72B3D400C ON mod_mod (mod_source)');
        $this->addSql('CREATE INDEX IDX_99C60BF732D81083 ON mod_mod (mod_target)');
        $this->addSql('CREATE TABLE mod_modpack (mod_id INT NOT NULL, modpack_id INT NOT NULL, PRIMARY KEY (mod_id, modpack_id))');
        $this->addSql('CREATE INDEX IDX_9449C4F4338E21CD ON mod_modpack (mod_id)');
        $this->addSql('CREATE INDEX IDX_9449C4F4949D6AEB ON mod_modpack (modpack_id)');
        $this->addSql('CREATE TABLE modpack (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, version VARCHAR(50) NOT NULL, PRIMARY KEY (id))');
        $this->addSql('CREATE UNIQUE INDEX UNIQ_54871F66BF1CD3C3 ON modpack (version)');
        $this->addSql('CREATE TABLE publication (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, date TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, contenu TEXT NOT NULL, author_id INT NOT NULL, categorie_id INT NOT NULL, PRIMARY KEY (id))');
        $this->addSql('CREATE INDEX IDX_AF3C6779F675F31B ON publication (author_id)');
        $this->addSql('CREATE INDEX IDX_AF3C6779BCF5E72D ON publication (categorie_id)');
        $this->addSql('CREATE TABLE session (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, debut TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, fin TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, joueur_id UUID NOT NULL, PRIMARY KEY (id))');
        $this->addSql('CREATE INDEX IDX_D044D5D4A9E2D76C ON session (joueur_id)');
        $this->addSql('CREATE TABLE territoire (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, x INT NOT NULL, z INT NOT NULL, description TEXT NOT NULL, PRIMARY KEY (id))');
        $this->addSql('CREATE TABLE territoire_joueur (territoire_id INT NOT NULL, joueur_id UUID NOT NULL, PRIMARY KEY (territoire_id, joueur_id))');
        $this->addSql('CREATE INDEX IDX_A714A788D0F97A8 ON territoire_joueur (territoire_id)');
        $this->addSql('CREATE INDEX IDX_A714A788A9E2D76C ON territoire_joueur (joueur_id)');
        $this->addSql('CREATE TABLE "user" (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, pseudo VARCHAR(180) NOT NULL, roles JSON NOT NULL, password VARCHAR(255) NOT NULL, uri_pp VARCHAR(255) DEFAULT NULL, theme_sombre BOOLEAN NOT NULL, joueur_id UUID DEFAULT NULL, creator_id INT DEFAULT NULL, PRIMARY KEY (id))');
        $this->addSql('CREATE UNIQUE INDEX UNIQ_8D93D649A9E2D76C ON "user" (joueur_id)');
        $this->addSql('CREATE INDEX IDX_8D93D64961220EA6 ON "user" (creator_id)');
        $this->addSql('CREATE UNIQUE INDEX UNIQ_IDENTIFIER_PSEUDO ON "user" (pseudo)');
        $this->addSql('CREATE TABLE messenger_messages (id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, body TEXT NOT NULL, headers TEXT NOT NULL, queue_name VARCHAR(190) NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, available_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, delivered_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY (id))');
        $this->addSql('CREATE INDEX IDX_75EA56E0FB7336F0E3BD61CE16BA31DBBF396750 ON messenger_messages (queue_name, available_at, delivered_at, id)');
        $this->addSql('ALTER TABLE constitue ADD CONSTRAINT FK_AA077561338E21CD FOREIGN KEY (mod_id) REFERENCES mod (id) NOT DEFERRABLE');
        $this->addSql('ALTER TABLE constitue ADD CONSTRAINT FK_AA077561949D6AEB FOREIGN KEY (modpack_id) REFERENCES modpack (id) NOT DEFERRABLE');
        $this->addSql('ALTER TABLE illustration ADD CONSTRAINT FK_D67B9A4238B217A7 FOREIGN KEY (publication_id) REFERENCES publication (id) NOT DEFERRABLE');
        $this->addSql('ALTER TABLE mod_mod ADD CONSTRAINT FK_99C60BF72B3D400C FOREIGN KEY (mod_source) REFERENCES mod (id) ON DELETE CASCADE');
        $this->addSql('ALTER TABLE mod_mod ADD CONSTRAINT FK_99C60BF732D81083 FOREIGN KEY (mod_target) REFERENCES mod (id) ON DELETE CASCADE');
        $this->addSql('ALTER TABLE mod_modpack ADD CONSTRAINT FK_9449C4F4338E21CD FOREIGN KEY (mod_id) REFERENCES mod (id) ON DELETE CASCADE');
        $this->addSql('ALTER TABLE mod_modpack ADD CONSTRAINT FK_9449C4F4949D6AEB FOREIGN KEY (modpack_id) REFERENCES modpack (id) ON DELETE CASCADE');
        $this->addSql('ALTER TABLE publication ADD CONSTRAINT FK_AF3C6779F675F31B FOREIGN KEY (author_id) REFERENCES "user" (id) NOT DEFERRABLE');
        $this->addSql('ALTER TABLE publication ADD CONSTRAINT FK_AF3C6779BCF5E72D FOREIGN KEY (categorie_id) REFERENCES categorie_publication (id) NOT DEFERRABLE');
        $this->addSql('ALTER TABLE session ADD CONSTRAINT FK_D044D5D4A9E2D76C FOREIGN KEY (joueur_id) REFERENCES joueur (id) NOT DEFERRABLE');
        $this->addSql('ALTER TABLE territoire_joueur ADD CONSTRAINT FK_A714A788D0F97A8 FOREIGN KEY (territoire_id) REFERENCES territoire (id) ON DELETE CASCADE');
        $this->addSql('ALTER TABLE territoire_joueur ADD CONSTRAINT FK_A714A788A9E2D76C FOREIGN KEY (joueur_id) REFERENCES joueur (id) ON DELETE CASCADE');
        $this->addSql('ALTER TABLE "user" ADD CONSTRAINT FK_8D93D649A9E2D76C FOREIGN KEY (joueur_id) REFERENCES joueur (id)');
        $this->addSql('ALTER TABLE "user" ADD CONSTRAINT FK_8D93D64961220EA6 FOREIGN KEY (creator_id) REFERENCES "user" (id)');
    }

    public function down(Schema $schema): void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE constitue DROP CONSTRAINT FK_AA077561338E21CD');
        $this->addSql('ALTER TABLE constitue DROP CONSTRAINT FK_AA077561949D6AEB');
        $this->addSql('ALTER TABLE illustration DROP CONSTRAINT FK_D67B9A4238B217A7');
        $this->addSql('ALTER TABLE mod_mod DROP CONSTRAINT FK_99C60BF72B3D400C');
        $this->addSql('ALTER TABLE mod_mod DROP CONSTRAINT FK_99C60BF732D81083');
        $this->addSql('ALTER TABLE mod_modpack DROP CONSTRAINT FK_9449C4F4338E21CD');
        $this->addSql('ALTER TABLE mod_modpack DROP CONSTRAINT FK_9449C4F4949D6AEB');
        $this->addSql('ALTER TABLE publication DROP CONSTRAINT FK_AF3C6779F675F31B');
        $this->addSql('ALTER TABLE publication DROP CONSTRAINT FK_AF3C6779BCF5E72D');
        $this->addSql('ALTER TABLE session DROP CONSTRAINT FK_D044D5D4A9E2D76C');
        $this->addSql('ALTER TABLE territoire_joueur DROP CONSTRAINT FK_A714A788D0F97A8');
        $this->addSql('ALTER TABLE territoire_joueur DROP CONSTRAINT FK_A714A788A9E2D76C');
        $this->addSql('ALTER TABLE "user" DROP CONSTRAINT FK_8D93D649A9E2D76C');
        $this->addSql('ALTER TABLE "user" DROP CONSTRAINT FK_8D93D64961220EA6');
        $this->addSql('DROP TABLE categorie_publication');
        $this->addSql('DROP TABLE constitue');
        $this->addSql('DROP TABLE illustration');
        $this->addSql('DROP TABLE joueur');
        $this->addSql('DROP TABLE mod');
        $this->addSql('DROP TABLE mod_mod');
        $this->addSql('DROP TABLE mod_modpack');
        $this->addSql('DROP TABLE modpack');
        $this->addSql('DROP TABLE publication');
        $this->addSql('DROP TABLE session');
        $this->addSql('DROP TABLE territoire');
        $this->addSql('DROP TABLE territoire_joueur');
        $this->addSql('DROP TABLE "user"');
        $this->addSql('DROP TABLE messenger_messages');
    }
}
