<?php

/*
 * This file is part of the VITICORE2 package.
 *
 * (c) CP Creation <web@cpcreation.fr>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace CpCreation\VitiCore\Bridge\Doctrine\Migrations;

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

/**
 * Auto-generated Migration: Please modify to your needs!
 */
final class Version20260521072715 extends AbstractMigration
{
    public function getDescription(): string
    {
        return '';
    }

    public function up(Schema $schema): void
    {
        $this->addSql('DROP SEQUENCE IF EXISTS history_history_image_id_seq CASCADE');
        $this->addSql('DROP SEQUENCE IF EXISTS season_season_image_id_seq CASCADE');
        $this->addSql('DROP TABLE IF EXISTS product_gift CASCADE');
        $this->addSql('DROP TABLE IF EXISTS newsletter_newsletter_translation CASCADE');
        $this->addSql('DROP TABLE IF EXISTS history_history_translation CASCADE');
        $this->addSql('DROP TABLE IF EXISTS history_history_image CASCADE');
        $this->addSql('DROP TABLE IF EXISTS history_history CASCADE');
        $this->addSql('DROP TABLE IF EXISTS newsletter_newsletter CASCADE');
        $this->addSql('DROP TABLE IF EXISTS season_season CASCADE');
        $this->addSql('DROP TABLE IF EXISTS season_season_image CASCADE');
        $this->addSql('DROP TABLE IF EXISTS season_season_translation CASCADE');
        $this->addSql('ALTER TABLE IF EXISTS client_email_group_mapping ALTER id DROP DEFAULT');
        $this->addSql('ALTER INDEX IF EXISTS uniq_client_email_group_mapping_email RENAME TO UNIQ_200CE121E7927C74');
        $this->addSql('ALTER TABLE IF EXISTS contact_contact DROP COLUMN IF EXISTS recaptcha');
        $this->addSql('ALTER TABLE IF EXISTS contact_contact DROP COLUMN IF EXISTS recaptcha_key_public');
        $this->addSql('ALTER TABLE IF EXISTS contact_contact DROP COLUMN IF EXISTS recaptcha_key_private');
        $this->addSql('ALTER TABLE IF EXISTS product_type DROP COLUMN IF EXISTS gift');
        $this->addSql('ALTER TABLE IF EXISTS shop_shop_config DROP COLUMN IF EXISTS gift_card_check_token');
        $this->addSql('ALTER TABLE IF EXISTS shop_shop_config DROP COLUMN IF EXISTS gift_card_valid_time');
    }

    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('CREATE SEQUENCE history_history_image_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
        $this->addSql('CREATE SEQUENCE season_season_image_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
        $this->addSql('CREATE TABLE product_gift (id UUID NOT NULL, cart_item_id UUID DEFAULT NULL, token VARCHAR(8) NOT NULL, used_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, valid_until_date TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE INDEX idx_2994bbace9b59a59 ON product_gift (cart_item_id)');
        $this->addSql('COMMENT ON COLUMN product_gift.id IS \'(DC2Type:uuid)\'');
        $this->addSql('COMMENT ON COLUMN product_gift.cart_item_id IS \'(DC2Type:uuid)\'');
        $this->addSql('CREATE TABLE newsletter_newsletter_translation (id UUID NOT NULL, translatable_id UUID DEFAULT NULL, title TEXT NOT NULL, slug VARCHAR(255) NOT NULL, locale VARCHAR(5) NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE INDEX idx_499f1f502c2ac5d3 ON newsletter_newsletter_translation (translatable_id)');
        $this->addSql('CREATE UNIQUE INDEX newsletter_newsletter_translation_unique_translation ON newsletter_newsletter_translation (translatable_id, locale)');
        $this->addSql('CREATE UNIQUE INDEX uniq_499f1f50989d9b62 ON newsletter_newsletter_translation (slug)');
        $this->addSql('COMMENT ON COLUMN newsletter_newsletter_translation.id IS \'(DC2Type:uuid)\'');
        $this->addSql('COMMENT ON COLUMN newsletter_newsletter_translation.translatable_id IS \'(DC2Type:uuid)\'');
        $this->addSql('CREATE TABLE history_history_translation (id UUID NOT NULL, translatable_id UUID DEFAULT NULL, title TEXT NOT NULL, subtitle TEXT DEFAULT NULL, text TEXT NOT NULL, slug VARCHAR(255) NOT NULL, locale VARCHAR(5) NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE UNIQUE INDEX history_history_translation_unique_translation ON history_history_translation (translatable_id, locale)');
        $this->addSql('CREATE INDEX idx_e84178392c2ac5d3 ON history_history_translation (translatable_id)');
        $this->addSql('CREATE UNIQUE INDEX uniq_e8417839989d9b62 ON history_history_translation (slug)');
        $this->addSql('COMMENT ON COLUMN history_history_translation.id IS \'(DC2Type:uuid)\'');
        $this->addSql('COMMENT ON COLUMN history_history_translation.translatable_id IS \'(DC2Type:uuid)\'');
        $this->addSql('CREATE TABLE history_history_image (id INT NOT NULL, history_id UUID DEFAULT NULL, image_id UUID DEFAULT NULL, "position" INT DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE INDEX idx_b6ded75f1e058452 ON history_history_image (history_id)');
        $this->addSql('CREATE UNIQUE INDEX uniq_b6ded75f3da5256d ON history_history_image (image_id)');
        $this->addSql('COMMENT ON COLUMN history_history_image.history_id IS \'(DC2Type:uuid)\'');
        $this->addSql('COMMENT ON COLUMN history_history_image.image_id IS \'(DC2Type:uuid)\'');
        $this->addSql('COMMENT ON COLUMN history_history_image.created_at IS \'(DC2Type:datetime_immutable)\'');
        $this->addSql('COMMENT ON COLUMN history_history_image.updated_at IS \'(DC2Type:datetime_immutable)\'');
        $this->addSql('CREATE TABLE history_history (id UUID NOT NULL, file_id UUID DEFAULT NULL, video_id UUID DEFAULT NULL, "position" INT NOT NULL, disabled BOOLEAN DEFAULT false NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE UNIQUE INDEX uniq_3dd5ca129c1004e ON history_history (video_id)');
        $this->addSql('CREATE UNIQUE INDEX uniq_3dd5ca193cb796c ON history_history (file_id)');
        $this->addSql('COMMENT ON COLUMN history_history.id IS \'(DC2Type:uuid)\'');
        $this->addSql('COMMENT ON COLUMN history_history.file_id IS \'(DC2Type:uuid)\'');
        $this->addSql('COMMENT ON COLUMN history_history.video_id IS \'(DC2Type:uuid)\'');
        $this->addSql('COMMENT ON COLUMN history_history.created_at IS \'(DC2Type:datetime_immutable)\'');
        $this->addSql('COMMENT ON COLUMN history_history.updated_at IS \'(DC2Type:datetime_immutable)\'');
        $this->addSql('CREATE TABLE newsletter_newsletter (id UUID NOT NULL, file_id UUID DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE UNIQUE INDEX uniq_9390bc6293cb796c ON newsletter_newsletter (file_id)');
        $this->addSql('COMMENT ON COLUMN newsletter_newsletter.id IS \'(DC2Type:uuid)\'');
        $this->addSql('COMMENT ON COLUMN newsletter_newsletter.file_id IS \'(DC2Type:uuid)\'');
        $this->addSql('COMMENT ON COLUMN newsletter_newsletter.created_at IS \'(DC2Type:datetime_immutable)\'');
        $this->addSql('COMMENT ON COLUMN newsletter_newsletter.updated_at IS \'(DC2Type:datetime_immutable)\'');
        $this->addSql('CREATE TABLE season_season (id UUID NOT NULL, video_id UUID DEFAULT NULL, "position" INT DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE UNIQUE INDEX uniq_e69fa51b29c1004e ON season_season (video_id)');
        $this->addSql('COMMENT ON COLUMN season_season.id IS \'(DC2Type:uuid)\'');
        $this->addSql('COMMENT ON COLUMN season_season.video_id IS \'(DC2Type:uuid)\'');
        $this->addSql('COMMENT ON COLUMN season_season.created_at IS \'(DC2Type:datetime_immutable)\'');
        $this->addSql('COMMENT ON COLUMN season_season.updated_at IS \'(DC2Type:datetime_immutable)\'');
        $this->addSql('CREATE TABLE season_season_image (id INT NOT NULL, season_id UUID DEFAULT NULL, image_id UUID DEFAULT NULL, "position" INT DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE INDEX idx_d69f579d4ec001d1 ON season_season_image (season_id)');
        $this->addSql('CREATE UNIQUE INDEX uniq_d69f579d3da5256d ON season_season_image (image_id)');
        $this->addSql('COMMENT ON COLUMN season_season_image.season_id IS \'(DC2Type:uuid)\'');
        $this->addSql('COMMENT ON COLUMN season_season_image.image_id IS \'(DC2Type:uuid)\'');
        $this->addSql('COMMENT ON COLUMN season_season_image.created_at IS \'(DC2Type:datetime_immutable)\'');
        $this->addSql('COMMENT ON COLUMN season_season_image.updated_at IS \'(DC2Type:datetime_immutable)\'');
        $this->addSql('CREATE TABLE season_season_translation (id UUID NOT NULL, translatable_id UUID DEFAULT NULL, title TEXT NOT NULL, slug VARCHAR(255) NOT NULL, subtitle TEXT NOT NULL, first_text TEXT NOT NULL, second_text TEXT DEFAULT NULL, locale VARCHAR(5) NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE INDEX idx_6ef8836c2c2ac5d3 ON season_season_translation (translatable_id)');
        $this->addSql('CREATE UNIQUE INDEX season_season_translation_unique_translation ON season_season_translation (translatable_id, locale)');
        $this->addSql('CREATE UNIQUE INDEX uniq_6ef8836c989d9b62 ON season_season_translation (slug)');
        $this->addSql('COMMENT ON COLUMN season_season_translation.id IS \'(DC2Type:uuid)\'');
        $this->addSql('COMMENT ON COLUMN season_season_translation.translatable_id IS \'(DC2Type:uuid)\'');
        $this->addSql('ALTER TABLE product_gift ADD CONSTRAINT fk_2994bbace9b59a59 FOREIGN KEY (cart_item_id) REFERENCES cart_cart_item (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE newsletter_newsletter_translation ADD CONSTRAINT fk_499f1f502c2ac5d3 FOREIGN KEY (translatable_id) REFERENCES newsletter_newsletter (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE history_history_translation ADD CONSTRAINT fk_e84178392c2ac5d3 FOREIGN KEY (translatable_id) REFERENCES history_history (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE history_history_image ADD CONSTRAINT fk_b6ded75f1e058452 FOREIGN KEY (history_id) REFERENCES history_history (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE history_history_image ADD CONSTRAINT fk_b6ded75f3da5256d FOREIGN KEY (image_id) REFERENCES media_media (id) ON DELETE SET NULL NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE history_history ADD CONSTRAINT fk_3dd5ca129c1004e FOREIGN KEY (video_id) REFERENCES media_media (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE history_history ADD CONSTRAINT fk_3dd5ca193cb796c FOREIGN KEY (file_id) REFERENCES media_media (id) ON DELETE SET NULL NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE newsletter_newsletter ADD CONSTRAINT fk_9390bc6293cb796c FOREIGN KEY (file_id) REFERENCES media_media (id) ON DELETE SET NULL NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE season_season ADD CONSTRAINT fk_e69fa51b29c1004e FOREIGN KEY (video_id) REFERENCES media_media (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE season_season_image ADD CONSTRAINT fk_d69f579d3da5256d FOREIGN KEY (image_id) REFERENCES media_media (id) ON DELETE SET NULL NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE season_season_image ADD CONSTRAINT fk_d69f579d4ec001d1 FOREIGN KEY (season_id) REFERENCES season_season (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE season_season_translation ADD CONSTRAINT fk_6ef8836c2c2ac5d3 FOREIGN KEY (translatable_id) REFERENCES season_season (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE contact_contact ADD recaptcha BOOLEAN NOT NULL');
        $this->addSql('ALTER TABLE contact_contact ADD recaptcha_key_public TEXT DEFAULT NULL');
        $this->addSql('ALTER TABLE contact_contact ADD recaptcha_key_private TEXT DEFAULT NULL');
        $this->addSql('ALTER TABLE product_type ADD gift BOOLEAN DEFAULT false NOT NULL');
        $this->addSql('ALTER TABLE shop_shop_config ADD gift_card_check_token VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE shop_shop_config ADD gift_card_valid_time VARCHAR(255) DEFAULT NULL');
        $this->addSql('COMMENT ON COLUMN shop_shop_config.gift_card_valid_time IS \'(DC2Type:dateinterval)\'');
        $this->addSql('CREATE SEQUENCE client_email_group_mapping_id_seq');
        $this->addSql('SELECT setval(\'client_email_group_mapping_id_seq\', (SELECT MAX(id) FROM client_email_group_mapping))');
        $this->addSql('ALTER TABLE client_email_group_mapping ALTER id SET DEFAULT nextval(\'client_email_group_mapping_id_seq\')');
        $this->addSql('ALTER INDEX uniq_200ce121e7927c74 RENAME TO uniq_client_email_group_mapping_email');
    }
}
