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
|
|
|
|