Passed
Branch master (bbfb46)
by Jan
22:41 queued 14:44
created

Migration1536233210SalesChannelDomain   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 3
dl 0
loc 36
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Core\Migration;
4
5
use Doctrine\DBAL\Connection;
6
use Shopware\Core\Framework\Migration\MigrationStep;
7
8
class Migration1536233210SalesChannelDomain extends MigrationStep
9
{
10
    public function getCreationTimestamp(): int
11
    {
12
        return 1536233210;
13
    }
14
15
    public function update(Connection $connection): void
16
    {
17
        $connection->exec('
18
            CREATE TABLE sales_channel_domain (
19
            `id` BINARY(16) NOT NULL PRIMARY KEY,
20
            `sales_channel_id` BINARY(16) NOT NULL,
21
            `language_id` BINARY(16) NOT NULL,
22
            `url` VARCHAR(255) NOT NULL,
23
            `currency_id` BINARY(16) NOT NULL,
24
            `snippet_set_id` BINARY(16) NOT NULL,
25
            `custom_fields` JSON NULL,
26
            `created_at` DATETIME(3) NOT NULL,
27
            `updated_at` DATETIME(3) NULL,
28
            CONSTRAINT `json.sales_channel_domain.custom_fields` CHECK (JSON_VALID(`custom_fields`)),
29
            CONSTRAINT `fk.sales_channel_domain.sales_channel_id` FOREIGN KEY (sales_channel_id) 
30
              REFERENCES `sales_channel` (id) ON DELETE CASCADE ON UPDATE CASCADE,
31
            CONSTRAINT `fk.sales_channel_domain.language_id` FOREIGN KEY (sales_channel_id, language_id) 
32
              REFERENCES `sales_channel_language` (sales_channel_id, language_id) ON DELETE RESTRICT ON UPDATE CASCADE,
33
            CONSTRAINT `fk.sales_channel_domain.currency_id` FOREIGN KEY (currency_id) 
34
              REFERENCES `currency` (id) ON DELETE RESTRICT ON UPDATE CASCADE,
35
            CONSTRAINT `fk.sales_channel_domain.snippet_set_id` FOREIGN KEY (snippet_set_id) 
36
              REFERENCES `snippet_set` (id) ON DELETE RESTRICT ON UPDATE CASCADE,
37
            CONSTRAINT `uniq.sales_channel_domain.url` UNIQUE(url)
38
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
39
        ');
40
    }
41
42
    public function updateDestructive(Connection $connection): void
43
    {
44
        // implement update destructive
45
    }
46
}
47