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

Migration1536232650CustomerGroup   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 4
dl 0
loc 39
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 Migration1536232650CustomerGroup extends MigrationStep
9
{
10
    public function getCreationTimestamp(): int
11
    {
12
        return 1536232650;
13
    }
14
15
    public function update(Connection $connection): void
16
    {
17
        $connection->executeQuery('
18
            CREATE TABLE `customer_group` (
19
              `id`              BINARY(16)  NOT NULL,
20
              `display_gross`   TINYINT(1)  NOT NULL DEFAULT 1,
21
              `created_at`      DATETIME(3) NOT NULL,
22
              `updated_at`      DATETIME(3) NULL,
23
              PRIMARY KEY (`id`)
24
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
25
        ');
26
27
        $connection->executeQuery('
28
            CREATE TABLE `customer_group_translation` (
29
              `customer_group_id`   BINARY(16)                              NOT NULL,
30
              `language_id`         BINARY(16)                              NOT NULL,
31
              `name`                VARCHAR(255) COLLATE utf8mb4_unicode_ci NULL,
32
              `custom_fields`       JSON                                    NULL,
33
              `created_at`          DATETIME(3)                             NOT NULL,
34
              `updated_at`          DATETIME(3)                             NULL,
35
              PRIMARY KEY (`customer_group_id`, `language_id`),
36
              CONSTRAINT `json.customer_group_translation.custom_fields` CHECK (JSON_VALID(`custom_fields`)),
37
              CONSTRAINT `fk.customer_group_translation.language_id`
38
                FOREIGN KEY (`language_id`) REFERENCES `language` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
39
              CONSTRAINT `fk.customer_group_translation.customer_group_id`
40
                FOREIGN KEY (`customer_group_id`) REFERENCES `customer_group` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
41
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
42
        ');
43
    }
44
45
    public function updateDestructive(Connection $connection): void
46
    {
47
        // implement update destructive
48
    }
49
}
50