m200818_131101_create_record_table::safeDown()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
use yii\db\Migration;
4
5
/**
6
 * Handles the creation of table `{{%record}}`.
7
 */
8
class m200818_131101_create_record_table extends Migration
9
{
10
    /**
11
     * {@inheritdoc}
12
     */
13
    public function safeUp()
14
    {
15
        $this->createTable('{{%record}}', [
16
            'id' => $this->primaryKey(),
17
            'user_id' => $this->integer()->notNull(),
18
            'account_id' => $this->integer()->notNull(),
19
            'category_id' => $this->integer()->notNull(),
20
            'amount_cent' => $this->integer()->notNull(), // base currency
21
            'currency_amount_cent' => $this->integer()->notNull(),
22
            'currency_code' => $this->string(3)->notNull(),
23
            'transaction_id' => $this->integer(),
24
            'direction' => $this->tinyInteger()->notNull(),
25
            'date' => $this->timestamp()->notNull(),
26
            'created_at' => $this->timestamp()->defaultValue(null),
27
            'updated_at' => $this->timestamp()->defaultValue(null),
28
        ]);
29
30
        $this->createIndex('record_user_id_transaction_id', '{{%record}}', ['user_id', 'transaction_id']);
31
        $this->createIndex('record_user_id_account_id', '{{%record}}', ['user_id', 'account_id']);
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function safeDown()
38
    {
39
        $this->dropTable('{{%record}}');
40
    }
41
}
42