migrations/Version20250526111629.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. final class Version20250526111629 extends AbstractMigration
  7. {
  8.     public function getDescription(): string
  9.     {
  10.         return 'Add new entity order_setting';
  11.     }
  12.     public function up(Schema $schema): void
  13.     {
  14.         $this->addSql('CREATE TABLE order_setting (id INT AUTO_INCREMENT NOT NULL, shop_id INT NOT NULL, customer_identifier VARCHAR(255) DEFAULT NULL, cutlery TINYINT(1) DEFAULT 0 NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, UNIQUE INDEX UNIQ_690E11D34D16C4DD (shop_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  15.         $this->addSql('ALTER TABLE order_setting ADD CONSTRAINT FK_690E11D34D16C4DD FOREIGN KEY (shop_id) REFERENCES shop (id)');
  16.         $this->addSql('ALTER TABLE `order` ADD setting JSON DEFAULT NULL');
  17.         $this->addSql('
  18.             INSERT INTO order_setting (shop_id, created_at, updated_at)
  19.             SELECT id, NOW(), NOW() FROM shop
  20.         ');
  21.     }
  22.     public function down(Schema $schema): void
  23.     {
  24.         $this->addSql('ALTER TABLE order_setting DROP FOREIGN KEY FK_690E11D34D16C4DD');
  25.         $this->addSql('DROP TABLE order_setting');
  26.         $this->addSql('ALTER TABLE `order` DROP setting');
  27.     }
  28. }