m200828_095405_update_record_table   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 24
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A safeUp() 0 7 1
A safeDown() 0 7 1
1
<?php
2
3
use yii\db\Migration;
4
5
/**
6
 * Class m200828_095405_update_record_table
7
 */
8
class m200828_095405_update_record_table extends Migration
9
{
10
    /**
11
     * {@inheritdoc}
12
     */
13
    public function safeUp()
14
    {
15
        $this->alterColumn('{{record}}', 'date', $this->timestamp()->defaultValue(null));
16
        $this->alterColumn('{{transaction}}', 'date', $this->timestamp()->defaultValue(null));
17
18
        $this->addColumn('{{record}}', 'transaction_type', $this->tinyInteger()->after('account_id'));
19
        $this->addColumn('{{record}}', 'source', $this->tinyInteger()->after('date'));
20
    }
21
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function safeDown()
26
    {
27
        echo "m200828_095405_update_record_table cannot be reverted.\n";
28
        $this->dropColumn('{{record}}', 'transaction_type');
29
        $this->dropColumn('{{record}}', 'source');
30
31
        return true;
32
    }
33
34
    /*
35
    // Use up()/down() to run migration code without a transaction.
36
    public function up()
37
    {
38
39
    }
40
41
    public function down()
42
    {
43
        echo "m200828_095405_update_record_table cannot be reverted.\n";
44
45
        return false;
46
    }
47
    */
48
}
49