migrations/common/Version20220302_MerchantAttribute.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Migrations\Common;
  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 Version20220302_MerchantAttribute extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return 'Merchant attributes';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         $this->addSql("
  18.             CREATE TABLE merchant_attribute (
  19.                 id INT AUTO_INCREMENT NOT NULL, 
  20.                 merchant_id INT DEFAULT NULL, 
  21.                 attribute ENUM('pro_features', 'approve_zero') NOT NULL COMMENT '(DC2Type:merchant_attribute)', 
  22.                 PRIMARY KEY(id)
  23.             ) ENGINE = InnoDB;"
  24.         );
  25.         $this->addSql("
  26.             CREATE TABLE merchant_attribute_history (
  27.                 id INT AUTO_INCREMENT NOT NULL, 
  28.                 merchant_id INT DEFAULT NULL, 
  29.                 attribute ENUM('pro_features', 'approve_zero') NOT NULL COMMENT '(DC2Type:merchant_attribute)',
  30.                 action ENUM('add', 'remove') NOT NULL COMMENT '(DC2Type:merchant_attribute_action)',
  31.                 record_datetime DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', 
  32.                 PRIMARY KEY(id)
  33.             ) ENGINE = InnoDB;"
  34.         );
  35.         $this->addSql("ALTER TABLE merchant_attribute ADD CONSTRAINT FK_FC2826DD6796D554 FOREIGN KEY (merchant_id) REFERENCES merchant (id);");
  36.         $this->addSql("ALTER TABLE merchant_attribute_history ADD CONSTRAINT FK_4BCC45A6796D554 FOREIGN KEY (merchant_id) REFERENCES merchant (id);");
  37.     }
  38.     public function down(Schema $schema): void
  39.     {
  40.     }
  41. }