|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file was created by developers working at BitBag |
|
5
|
|
|
* Do you need more information about us and what we do? Visit our https://bitbag.io website! |
|
6
|
|
|
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
declare(strict_types=1); |
|
10
|
|
|
|
|
11
|
|
|
namespace BitBag\SyliusWishlistPlugin\Migrations; |
|
12
|
|
|
|
|
13
|
|
|
use Doctrine\DBAL\Schema\Schema; |
|
14
|
|
|
use Doctrine\Migrations\AbstractMigration; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @deprecated Since bitbag/wishlist-plugin 2.0: Doctrine migrations existing in a bundle will be removed, move migrations to the project directory. |
|
18
|
|
|
*/ |
|
19
|
|
|
final class Version20201029161558 extends AbstractMigration |
|
20
|
|
|
{ |
|
21
|
|
|
public function up(Schema $schema): void |
|
22
|
|
|
{ |
|
23
|
|
|
$this->addSql('CREATE TABLE bitbag_wishlist (id INT AUTO_INCREMENT NOT NULL, shop_user_id INT DEFAULT NULL, token VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_578D4E775F37A13B (token), UNIQUE INDEX UNIQ_578D4E77A45D93BF (shop_user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET UTF8 COLLATE `UTF8_unicode_ci` ENGINE = InnoDB'); |
|
24
|
|
|
$this->addSql('CREATE TABLE bitbag_wishlist_product (id INT AUTO_INCREMENT NOT NULL, wishlist_id INT NOT NULL, product_id INT DEFAULT NULL, variant_id INT DEFAULT NULL, INDEX IDX_3DBE67A0FB8E54CD (wishlist_id), INDEX IDX_3DBE67A04584665A (product_id), INDEX IDX_3DBE67A03B69A9AF (variant_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET UTF8 COLLATE `UTF8_unicode_ci` ENGINE = InnoDB'); |
|
25
|
|
|
$this->addSql('ALTER TABLE bitbag_wishlist ADD CONSTRAINT FK_578D4E77A45D93BF FOREIGN KEY (shop_user_id) REFERENCES sylius_shop_user (id) ON DELETE CASCADE'); |
|
26
|
|
|
$this->addSql('ALTER TABLE bitbag_wishlist_product ADD CONSTRAINT FK_3DBE67A0FB8E54CD FOREIGN KEY (wishlist_id) REFERENCES bitbag_wishlist (id)'); |
|
27
|
|
|
$this->addSql('ALTER TABLE bitbag_wishlist_product ADD CONSTRAINT FK_3DBE67A04584665A FOREIGN KEY (product_id) REFERENCES sylius_product (id)'); |
|
28
|
|
|
$this->addSql('ALTER TABLE bitbag_wishlist_product ADD CONSTRAINT FK_3DBE67A03B69A9AF FOREIGN KEY (variant_id) REFERENCES sylius_product_variant (id)'); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function down(Schema $schema): void |
|
32
|
|
|
{ |
|
33
|
|
|
$this->addSql('ALTER TABLE bitbag_wishlist_product DROP FOREIGN KEY FK_3DBE67A0FB8E54CD'); |
|
34
|
|
|
$this->addSql('DROP TABLE bitbag_wishlist'); |
|
35
|
|
|
$this->addSql('DROP TABLE bitbag_wishlist_product'); |
|
36
|
|
|
} |
|
37
|
|
|
} |
|
38
|
|
|
|