m181010_081033_provider_locks   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 5
dl 0
loc 62
ccs 0
cts 48
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A safeUp() 0 46 1
A safeDown() 0 6 1
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://flipboxfactory.com/software/patron/license
6
 * @link       https://www.flipboxfactory.com/software/patron/
7
 */
8
9
namespace flipbox\patron\migrations;
10
11
use craft\db\Migration;
12
use flipbox\patron\records\Provider;
13
use flipbox\patron\records\ProviderLock;
14
15
class m181010_081033_provider_locks extends Migration
16
{
17
    /**
18
     * @inheritdoc
19
     */
20
    public function safeUp()
21
    {
22
        $this->createTable(
23
            ProviderLock::tableName(),
24
            [
25
                'providerId' => $this->integer()->notNull(),
26
                'pluginId' => $this->integer()->notNull(),
27
                'dateCreated' => $this->dateTime()->notNull(),
28
                'dateUpdated' => $this->dateTime()->notNull(),
29
                'uid' => $this->uid(),
30
            ]
31
        );
32
33
        $this->addPrimaryKey(
34
            null,
35
            ProviderLock::tableName(),
36
            [
37
                'providerId',
38
                'pluginId'
39
            ]
40
        );
41
42
        $this->addForeignKey(
43
            $this->db->getForeignKeyName(
44
                ProviderLock::tableName(),
45
                'providerId'
46
            ),
47
            ProviderLock::tableName(),
48
            'providerId',
49
            Provider::tableName(),
50
            'id',
51
            'CASCADE'
52
        );
53
54
        $this->addForeignKey(
55
            $this->db->getForeignKeyName(
56
                ProviderLock::tableName(),
57
                'pluginId'
58
            ),
59
            ProviderLock::tableName(),
60
            'pluginId',
61
            '{{%plugins}}',
62
            'id',
63
            'CASCADE'
64
        );
65
    }
66
67
    /**
68
     * @inheritdoc
69
     */
70
    public function safeDown()
71
    {
72
        $this->dropTableIfExists(ProviderLock::tableName());
73
74
        return true;
75
    }
76
}
77