IntegrationConnections::safeDown()   A
last analyzed

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 2.0.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
                'name' => $this->string()->notNull(),
34
                'handle' => $this->string()->notNull(),
35
                'class' => $this->string()->notNull(),
36
                'settings' => $this->text(),
37
                'enabled' => $this->boolean(),
38
                'dateUpdated' => $this->dateTime()->notNull(),
39
                'dateCreated' => $this->dateTime()->notNull(),
40
                'uid' => $this->uid()
41
            ]
42
        );
43
44
        $this->createIndex(
45
            $this->db->getIndexName(static::tableName(), 'handle', true),
46
            static::tableName(),
47
            'handle',
48
            true
49
        );
50
    }
51
52
    /**
53
     * @inheritdoc
54
     */
55
    public function safeDown()
56
    {
57
        $this->dropTableIfExists(static::tableName());
58
        return true;
59
    }
60
}
61