migrations/Version20251205173211.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. /**
  7.  * Auto-generated Migration: Please modify to your needs!
  8.  */
  9. final class Version20251205173211 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return 'Create app_product_decreasing table and add decreasing fields to app_payment_history and app_subscription';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         // this up() migration is auto-generated, please modify it to your needs
  18.         $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');
  19.         $this->addSql('ALTER TABLE app_product_decreasing ADD CONSTRAINT FK_PRODUCT_DECREASING_PRODUCT FOREIGN KEY (product_id) REFERENCES app_product (id)');
  20.         $this->addSql('ALTER TABLE app_product_decreasing ADD CONSTRAINT FK_PRODUCT_DECREASING_MARKET FOREIGN KEY (market_id) REFERENCES app_market (id)');
  21.         $this->addSql('ALTER TABLE app_payment_history ADD is_decreasing TINYINT(1) DEFAULT 0 NOT NULL, ADD decreasing_config_price JSON DEFAULT NULL');
  22.         $this->addSql('ALTER TABLE app_subscription ADD decreasing_config_price JSON DEFAULT NULL, ADD is_decreasing TINYINT(1) DEFAULT 0 NOT NULL');
  23.         $this->addSql('ALTER TABLE app_member ADD step_elite INT DEFAULT NULL');
  24.         $this->addSql('ALTER TABLE app_product_price ADD COLUMN is_enabled TINYINT NOT NULL DEFAULT 1;');
  25.     }
  26.     public function down(Schema $schema): void
  27.     {
  28.         // this down() migration is auto-generated, please modify it to your needs
  29.         $this->addSql('ALTER TABLE app_payment_history DROP is_decreasing, DROP decreasing_config_price');
  30.         $this->addSql('ALTER TABLE app_subscription DROP decreasing_config_price, DROP is_decreasing');
  31.         $this->addSql('ALTER TABLE app_product_decreasing DROP FOREIGN KEY FK_PRODUCT_DECREASING_PRODUCT');
  32.         $this->addSql('ALTER TABLE app_product_decreasing DROP FOREIGN KEY FK_PRODUCT_DECREASING_MARKET');
  33.         $this->addSql('DROP TABLE app_product_decreasing');
  34.     }
  35. }