<?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 Version20260402202554 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 advert (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, order_number_id INT NOT NULL, devis_id INT DEFAULT NULL, PRIMARY KEY (id))');
        $this->addSql('CREATE UNIQUE INDEX UNIQ_54F1F40B8C26A5E8 ON advert (order_number_id)');
        $this->addSql('CREATE INDEX IDX_54F1F40B41DEFADA ON advert (devis_id)');
        $this->addSql('CREATE TABLE devis (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, order_number_id INT NOT NULL, PRIMARY KEY (id))');
        $this->addSql('CREATE UNIQUE INDEX UNIQ_8B27C52B8C26A5E8 ON devis (order_number_id)');
        $this->addSql('CREATE TABLE "order" (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, split_index SMALLINT DEFAULT 0 NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, order_number_id INT NOT NULL, advert_id INT DEFAULT NULL, PRIMARY KEY (id))');
        $this->addSql('CREATE UNIQUE INDEX UNIQ_F52993988C26A5E8 ON "order" (order_number_id)');
        $this->addSql('CREATE INDEX IDX_F5299398D07ECCB6 ON "order" (advert_id)');
        $this->addSql('ALTER TABLE advert ADD CONSTRAINT FK_54F1F40B8C26A5E8 FOREIGN KEY (order_number_id) REFERENCES order_number (id) NOT DEFERRABLE');
        $this->addSql('ALTER TABLE advert ADD CONSTRAINT FK_54F1F40B41DEFADA FOREIGN KEY (devis_id) REFERENCES devis (id) NOT DEFERRABLE');
        $this->addSql('ALTER TABLE devis ADD CONSTRAINT FK_8B27C52B8C26A5E8 FOREIGN KEY (order_number_id) REFERENCES order_number (id) NOT DEFERRABLE');
        $this->addSql('ALTER TABLE "order" ADD CONSTRAINT FK_F52993988C26A5E8 FOREIGN KEY (order_number_id) REFERENCES order_number (id) NOT DEFERRABLE');
        $this->addSql('ALTER TABLE "order" ADD CONSTRAINT FK_F5299398D07ECCB6 FOREIGN KEY (advert_id) REFERENCES advert (id) NOT DEFERRABLE');
    }

    public function down(Schema $schema): void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE advert DROP CONSTRAINT FK_54F1F40B8C26A5E8');
        $this->addSql('ALTER TABLE advert DROP CONSTRAINT FK_54F1F40B41DEFADA');
        $this->addSql('ALTER TABLE devis DROP CONSTRAINT FK_8B27C52B8C26A5E8');
        $this->addSql('ALTER TABLE "order" DROP CONSTRAINT FK_F52993988C26A5E8');
        $this->addSql('ALTER TABLE "order" DROP CONSTRAINT FK_F5299398D07ECCB6');
        $this->addSql('DROP TABLE advert');
        $this->addSql('DROP TABLE devis');
        $this->addSql('DROP TABLE "order"');
    }
}
