Passed
Push — master ( 60ba83...d66857 )
by Damian
05:12
created

Version20201029161558::up()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 8
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BitBag\SyliusWishlistPlugin\Migrations;
6
7
use Doctrine\DBAL\Schema\Schema;
8
use Doctrine\Migrations\AbstractMigration;
9
10
final class Version20201029161558 extends AbstractMigration
11
{
12
    public function up(Schema $schema): void
13
    {
14
        $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');
15
        $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');
16
        $this->addSql('ALTER TABLE bitbag_wishlist ADD CONSTRAINT FK_578D4E77A45D93BF FOREIGN KEY (shop_user_id) REFERENCES sylius_shop_user (id) ON DELETE CASCADE');
17
        $this->addSql('ALTER TABLE bitbag_wishlist_product ADD CONSTRAINT FK_3DBE67A0FB8E54CD FOREIGN KEY (wishlist_id) REFERENCES bitbag_wishlist (id)');
18
        $this->addSql('ALTER TABLE bitbag_wishlist_product ADD CONSTRAINT FK_3DBE67A04584665A FOREIGN KEY (product_id) REFERENCES sylius_product (id)');
19
        $this->addSql('ALTER TABLE bitbag_wishlist_product ADD CONSTRAINT FK_3DBE67A03B69A9AF FOREIGN KEY (variant_id) REFERENCES sylius_product_variant (id)');
20
    }
21
22
    public function down(Schema $schema): void
23
    {
24
        $this->addSql('ALTER TABLE bitbag_wishlist_product DROP FOREIGN KEY FK_3DBE67A0FB8E54CD');
25
        $this->addSql('DROP TABLE bitbag_wishlist');
26
        $this->addSql('DROP TABLE bitbag_wishlist_product');
27
    }
28
}
29