<?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 Version20251205173211 extends AbstractMigration
{
public function getDescription(): string
{
return 'Create app_product_decreasing table and add decreasing fields to app_payment_history and app_subscription';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE app_product_decreasing (id INT AUTO_INCREMENT NOT NULL, product_id INT NOT NULL, market_id INT NOT NULL, point_config JSON DEFAULT NULL, price_config JSON DEFAULT NULL, commission_config JSON DEFAULT NULL, is_enabled TINYINT(1) DEFAULT 1 NOT NULL, copecart_product_id VARCHAR(255) DEFAULT NULL, INDEX IDX_PRODUCT_DECREASING_PRODUCT (product_id), INDEX IDX_PRODUCT_DECREASING_MARKET (market_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE app_product_decreasing ADD CONSTRAINT FK_PRODUCT_DECREASING_PRODUCT FOREIGN KEY (product_id) REFERENCES app_product (id)');
$this->addSql('ALTER TABLE app_product_decreasing ADD CONSTRAINT FK_PRODUCT_DECREASING_MARKET FOREIGN KEY (market_id) REFERENCES app_market (id)');
$this->addSql('ALTER TABLE app_payment_history ADD is_decreasing TINYINT(1) DEFAULT 0 NOT NULL, ADD decreasing_config_price JSON DEFAULT NULL');
$this->addSql('ALTER TABLE app_subscription ADD decreasing_config_price JSON DEFAULT NULL, ADD is_decreasing TINYINT(1) DEFAULT 0 NOT NULL');
$this->addSql('ALTER TABLE app_member ADD step_elite INT DEFAULT NULL');
$this->addSql('ALTER TABLE app_product_price ADD COLUMN is_enabled TINYINT NOT NULL DEFAULT 1;');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE app_payment_history DROP is_decreasing, DROP decreasing_config_price');
$this->addSql('ALTER TABLE app_subscription DROP decreasing_config_price, DROP is_decreasing');
$this->addSql('ALTER TABLE app_product_decreasing DROP FOREIGN KEY FK_PRODUCT_DECREASING_PRODUCT');
$this->addSql('ALTER TABLE app_product_decreasing DROP FOREIGN KEY FK_PRODUCT_DECREASING_MARKET');
$this->addSql('DROP TABLE app_product_decreasing');
}
}