Completed
Push — master ( 8ee345...bd0de2 )
by Nate
63:39 queued 61:56
created

IntegrationConnections::safeDown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
c 0
b 0
f 0
ccs 0
cts 5
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://github.com/flipboxfactory/craft-integration/blob/master/LICENSE
6
 * @link       https://github.com/flipboxfactory/craft-integration/
7
 */
8
9
namespace flipbox\craft\integration\migrations;
10
11
use craft\db\Migration;
12
13
/**
14
 * @author Flipbox Factory <[email protected]>
15
 * @since 1.1.0
16
 */
17
abstract class IntegrationConnections extends Migration
18
{
19
    /**
20
     * @return string
21
     */
22
    abstract protected static function tableName(): string;
23
24
    /**
25
     * @inheritdoc
26
     */
27
    public function safeUp()
28
    {
29
        $this->createTable(
30
            static::tableName(),
31
            [
32
                'id' => $this->primaryKey(),
33
                'handle' => $this->string()->notNull(),
34
                'class' => $this->string()->notNull(),
35
                'settings' => $this->text(),
36
                'enabled' => $this->boolean(),
37
                'dateUpdated' => $this->dateTime()->notNull(),
38
                'dateCreated' => $this->dateTime()->notNull(),
39
                'uid' => $this->uid()
40
            ]
41
        );
42
43
        $this->createIndex(
44
            $this->db->getIndexName(static::tableName(), 'handle', true),
45
            static::tableName(),
46
            'handle',
47
            true
48
        );
49
    }
50
51
    /**
52
     * @inheritdoc
53
     */
54
    public function safeDown()
55
    {
56
        $this->dropTableIfExists(static::tableName());
57
        return true;
58
    }
59
}
60