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

AlterEnvironments   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 5
dl 0
loc 38
ccs 0
cts 21
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A safeUp() 0 19 1
A safeDown() 0 4 1
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