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

Migration1536232870ShippingMethodPrice   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 3
dl 0
loc 40
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 Migration1536232870ShippingMethodPrice extends MigrationStep
9
{
10
    public function getCreationTimestamp(): int
11
    {
12
        return 1536232870;
13
    }
14
15
    public function update(Connection $connection): void
16
    {
17
        $connection->executeQuery('
18
            CREATE TABLE `shipping_method_price` (
19
              `id`                  BINARY(16)      NOT NULL,
20
              `shipping_method_id`  BINARY(16)      NOT NULL,
21
              `calculation`         INT(1) unsigned NULL,
22
              `rule_id`             BINARY(16)      NULL,
23
              `currency_id`         BINARY(16)      NOT NULL,
24
              `calculation_rule_id` BINARY(16) NULL,
25
              `price`               DOUBLE NOT NULL,
26
              `quantity_start`      DOUBLE NULL,
27
              `quantity_end`        DOUBLE NULL,
28
              `custom_fields`       JSON NULL,
29
              `created_at`          DATETIME(3) NOT NULL,
30
              `updated_at`          DATETIME(3) NULL,
31
              PRIMARY KEY (`id`),
32
              CONSTRAINT `uniq.shipping_method_quantity_start` UNIQUE KEY (`shipping_method_id`, `rule_id`, `currency_id`, `quantity_start`),
33
              CONSTRAINT `json.shipping_method_price.custom_fields` CHECK (JSON_VALID(`custom_fields`)),
34
              CONSTRAINT `fk.shipping_method_price.shipping_method_id` FOREIGN KEY (`shipping_method_id`) 
35
                REFERENCES `shipping_method` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
36
              CONSTRAINT `fk.shipping_method_price.currency_id` FOREIGN KEY (`currency_id`) 
37
                REFERENCES `currency` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
38
              CONSTRAINT `fk.shipping_method_price.rule_id` FOREIGN KEY (`rule_id`) 
39
                REFERENCES `rule` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
40
              CONSTRAINT `fk.shipping_method_price.calculation_rule_id` FOREIGN KEY (`calculation_rule_id`) 
41
                REFERENCES `rule` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
42
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
43
        ');
44
    }
45
46
    public function updateDestructive(Connection $connection): void
47
    {
48
        // implement update destructive
49
    }
50
}
51