Completed
Push — develop ( e45dbf...2d4657 )
by Nate
04:34
created

AlterEnvironments::safeUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 19
ccs 0
cts 17
cp 0
rs 9.6333
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://flipboxfactory.com/software/organization/license
6
 * @link       https://www.flipboxfactory.com/software/organization/
7
 */
8
9
namespace flipbox\patron\migrations;
10
11
use craft\db\Migration;
12
use flipbox\patron\Patron;
13
use flipbox\patron\records\ProviderEnvironment;
14
use flipbox\patron\records\TokenEnvironment;
15
16
/**
17
 * @author Flipbox Factory <[email protected]>
18
 * @since 1.0.0
19
 */
20
class AlterEnvironments extends Migration
21
{
22
    /**
23
     * The state column name
24
     */
25
    const COLUMN_NAME = 'environment';
26
27
    /**
28
     * @inheritdoc
29
     */
30
    public function safeUp()
31
    {
32
        $type = $this->enum(
33
            self::COLUMN_NAME,
34
            Patron::getInstance()->getSettings()->getEnvironments()
35
        )->notNull();
36
37
        $this->alterColumn(
38
            ProviderEnvironment::tableName(),
39
            self::COLUMN_NAME,
40
            $type
41
        );
42
43
        $this->alterColumn(
44
            TokenEnvironment::tableName(),
45
            self::COLUMN_NAME,
46
            $type
47
        );
48
    }
49
50
    /**
51
     * @inheritdoc
52
     */
53
    public function safeDown()
54
    {
55
        return false;
56
    }
57
}
58