migrations/Version20230712225731.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 Version20230712225731 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return '';
  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 customer_shops (id INT AUTO_INCREMENT NOT NULL, customer_id INT NOT NULL, shop_id INT NOT NULL, signup TINYINT(1) DEFAULT 0 NOT NULL, deleted TINYINT(1) DEFAULT 0 NOT NULL, deleted_at DATETIME DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX IDX_ED4F12B89395C3F3 (customer_id), INDEX IDX_ED4F12B84D16C4DD (shop_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  19.         $this->addSql('ALTER TABLE customer_shops ADD CONSTRAINT FK_ED4F12B89395C3F3 FOREIGN KEY (customer_id) REFERENCES user (id)');
  20.         $this->addSql('ALTER TABLE customer_shops ADD CONSTRAINT FK_ED4F12B84D16C4DD FOREIGN KEY (shop_id) REFERENCES shop (id)');
  21.         $this->addSql('INSERT INTO customer_shops (created_at, updated_at, customer_id, shop_id) SELECT NOW(), NOW(), customer_id, shop_id FROM customer_shop');
  22.         $this->addSql('ALTER TABLE customer_shop DROP FOREIGN KEY FK_F8FBE8D54D16C4DD');
  23.         $this->addSql('ALTER TABLE customer_shop DROP FOREIGN KEY FK_F8FBE8D59395C3F3');
  24.         $this->addSql('DROP TABLE customer_shop');
  25.         $this->addSql('ALTER TABLE customer_franchise ADD deleted TINYINT(1) DEFAULT 0 NOT NULL, ADD deleted_at DATETIME DEFAULT NULL');
  26.     }
  27.     public function down(Schema $schema): void
  28.     {
  29.         // this down() migration is auto-generated, please modify it to your needs
  30.         $this->addSql('CREATE TABLE customer_shop (customer_id INT NOT NULL, shop_id INT NOT NULL, INDEX IDX_F8FBE8D59395C3F3 (customer_id), INDEX IDX_F8FBE8D54D16C4DD (shop_id), PRIMARY KEY(customer_id, shop_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
  31.         $this->addSql('ALTER TABLE customer_shop ADD CONSTRAINT FK_F8FBE8D54D16C4DD FOREIGN KEY (shop_id) REFERENCES shop (id) ON DELETE CASCADE');
  32.         $this->addSql('ALTER TABLE customer_shop ADD CONSTRAINT FK_F8FBE8D59395C3F3 FOREIGN KEY (customer_id) REFERENCES user (id) ON DELETE CASCADE');
  33.         $this->addSql('INSERT INTO customer_shop (customer_id, shop_id) SELECT customer_id, shop_id FROM customer_shops');
  34.         $this->addSql('ALTER TABLE customer_shops DROP FOREIGN KEY FK_ED4F12B89395C3F3');
  35.         $this->addSql('ALTER TABLE customer_shops DROP FOREIGN KEY FK_ED4F12B84D16C4DD');
  36.         $this->addSql('DROP TABLE customer_shops');
  37.         $this->addSql('ALTER TABLE customer_franchise DROP deleted, DROP deleted_at');
  38.     }
  39. }