<?php

declare(strict_types=1);

namespace CpCreation\VitiCore\Bridge\Doctrine\Migrations;

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

final class Version20260603123000 extends AbstractMigration
{
    public function getDescription(): string
    {
        return 'Supprime les anciennes tables gite, page builder et product collection hors perimetre.';
    }

    public function up(Schema $schema): void
    {
        $this->addSql('DROP TABLE IF EXISTS gite_gite_image CASCADE');
        $this->addSql('DROP TABLE IF EXISTS gite_room_translation CASCADE');
        $this->addSql('DROP TABLE IF EXISTS gite_gite CASCADE');
        $this->addSql('DROP TABLE IF EXISTS page_builder_page_section_translation CASCADE');
        $this->addSql('DROP TABLE IF EXISTS gite_gite_translation CASCADE');
        $this->addSql('DROP TABLE IF EXISTS page_builder_page_translation CASCADE');
        $this->addSql('DROP TABLE IF EXISTS product_collection CASCADE');
        $this->addSql('DROP TABLE IF EXISTS gite_room_image CASCADE');
        $this->addSql('DROP TABLE IF EXISTS product_collection_translation CASCADE');
        $this->addSql('DROP TABLE IF EXISTS product_collection_item CASCADE');
        $this->addSql('DROP TABLE IF EXISTS gite_room CASCADE');
        $this->addSql('DROP TABLE IF EXISTS page_builder_page CASCADE');
        $this->addSql('DROP TABLE IF EXISTS page_builder_page_section CASCADE');
        $this->addSql('DROP SEQUENCE IF EXISTS gite_gite_image_id_seq CASCADE');
        $this->addSql('DROP SEQUENCE IF EXISTS gite_room_image_id_seq CASCADE');
        $this->addSql('DROP SEQUENCE IF EXISTS product_collection_item_id_seq CASCADE');
    }

    public function down(Schema $schema): void
    {
        $this->throwIrreversibleMigrationException('Les tables supprimees appartiennent a des fonctionnalites retirees ou a une autre branche.');
    }
}
