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

Migration1536233400MailTemplateMedia   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 16
dl 0
loc 28
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 Migration1536233400MailTemplateMedia extends MigrationStep
9
{
10
    public function getCreationTimestamp(): int
11
    {
12
        return 1536233400;
13
    }
14
15
    public function update(Connection $connection): void
16
    {
17
        $query = <<<SQL
18
            CREATE TABLE mail_template_media (
19
              id BINARY(16) NOT NULL,
20
              mail_template_id BINARY(16) NOT NULL,
21
              media_id BINARY(16) NOT NULL,
22
              position INT(11) NOT NULL DEFAULT 1,
23
              PRIMARY KEY (id),
24
              CONSTRAINT `fk.mail_template_media.mail_template_id` FOREIGN KEY (`mail_template_id`)
25
                REFERENCES `mail_template` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
26
              CONSTRAINT `fk.mail_template_media.media_id` FOREIGN KEY (`media_id`)
27
                REFERENCES `media` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
28
            )
29
SQL;
30
31
        $connection->exec($query);
32
    }
33
34
    public function updateDestructive(Connection $connection): void
35
    {
36
        // implement update destructive
37
    }
38
}
39