|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
use yii\db\Migration; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Handles the creation of table `{{%transaction}}`. |
|
7
|
|
|
*/ |
|
8
|
|
|
class m200818_130329_create_transaction_table extends Migration |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* {@inheritdoc} |
|
12
|
|
|
*/ |
|
13
|
|
|
public function safeUp() |
|
14
|
|
|
{ |
|
15
|
|
|
$this->createTable('{{%transaction}}', [ |
|
16
|
|
|
'id' => $this->primaryKey(), |
|
17
|
|
|
'user_id' => $this->integer()->notNull(), |
|
18
|
|
|
'from_account_id' => $this->integer(), |
|
19
|
|
|
'to_account_id' => $this->integer(), |
|
20
|
|
|
'type' => $this->tinyInteger()->notNull(), |
|
21
|
|
|
'category_id' => $this->integer()->notNull(), |
|
22
|
|
|
'amount_cent' => $this->integer()->notNull(), // base currency |
|
23
|
|
|
'currency_amount_cent' => $this->integer()->notNull(), |
|
24
|
|
|
'currency_code' => $this->string(3)->notNull(), |
|
25
|
|
|
'tags' => $this->string()->comment('Multiple choice use,'), |
|
26
|
|
|
'description' => $this->string(), |
|
27
|
|
|
'remark' => $this->string(), |
|
28
|
|
|
'image' => $this->string(), |
|
29
|
|
|
'status' => $this->tinyInteger()->defaultValue(1), |
|
30
|
|
|
'reimbursement_status' => $this->tinyInteger(), |
|
31
|
|
|
'rating' => $this->tinyInteger(), |
|
32
|
|
|
'date' => $this->timestamp()->notNull(), |
|
33
|
|
|
'created_at' => $this->timestamp()->defaultValue(null), |
|
34
|
|
|
'updated_at' => $this->timestamp()->defaultValue(null), |
|
35
|
|
|
]); |
|
36
|
|
|
|
|
37
|
|
|
$this->createIndex('transaction_user_id', '{{%transaction}}', 'user_id'); |
|
38
|
|
|
|
|
39
|
|
|
$this->execute("ALTER TABLE {{%transaction}} ADD FULLTEXT INDEX `full_text` (`description`, `tags`, `remark`)"); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* {@inheritdoc} |
|
44
|
|
|
*/ |
|
45
|
|
|
public function safeDown() |
|
46
|
|
|
{ |
|
47
|
|
|
$this->dropTable('{{%transaction}}'); |
|
48
|
|
|
} |
|
49
|
|
|
} |
|
50
|
|
|
|