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

Migration1536233200RuleCondition   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

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