<?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;

final class Version20260608120500 extends AbstractMigration
{
    public function getDescription(): string
    {
        return 'Remove unused shop award display limit.';
    }

    public function up(Schema $schema): void
    {
        if (!$schema->hasTable('shop_shop_config')) {
            return;
        }

        $table = $schema->getTable('shop_shop_config');

        if ($table->hasColumn('max_awards_visible_in_shop')) {
            $this->addSql('ALTER TABLE shop_shop_config DROP max_awards_visible_in_shop');
        }
    }

    public function down(Schema $schema): void
    {
        if (!$schema->hasTable('shop_shop_config')) {
            return;
        }

        $table = $schema->getTable('shop_shop_config');

        if (!$table->hasColumn('max_awards_visible_in_shop')) {
            $this->addSql('ALTER TABLE shop_shop_config ADD max_awards_visible_in_shop INT DEFAULT NULL');
        }
    }
}
