1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace console\migrations; |
4
|
|
|
|
5
|
|
|
use yii\db\Migration; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class M180204190759Logs |
9
|
|
|
*/ |
10
|
|
|
class M180204190759Logs extends Migration |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* @inheritdoc |
14
|
|
|
*/ |
15
|
|
|
public function safeUp() |
16
|
|
|
{ |
17
|
|
|
$this->createTable('{{%logs}}', [ |
18
|
|
|
'id' => $this->primaryKey(), |
19
|
|
|
'user' => $this->string()->notNull(), |
20
|
|
|
'user_ip' => $this->integer()->unsigned()->notNull(), |
21
|
|
|
'item_type' => $this->integer()->unsigned()->notNull(), |
22
|
|
|
'item_id' => $this->integer()->unsigned()->notNull(), |
23
|
|
|
'action' => $this->tinyInteger()->unsigned()->notNull(), |
24
|
|
|
'old_data' => $this->text(), |
25
|
|
|
'new_data' => $this->text(), |
26
|
|
|
'log_date' => $this->integer()->unsigned()->notNull(), |
27
|
|
|
]); |
28
|
|
|
$this->createIndex('idx_key_log_user', '{{%logs}}', ['user']); |
29
|
|
|
$this->createIndex('idx_key_log_action', '{{%logs}}', ['action']); |
30
|
|
|
$this->createIndex('idx_key_log_item', '{{%logs}}', ['item_type', 'item_id']); |
31
|
|
|
$this->createIndex('idx_key_log_date', '{{%logs}}', ['log_date']); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @inheritdoc |
36
|
|
|
*/ |
37
|
|
|
public function safeDown() |
38
|
|
|
{ |
39
|
|
|
$this->dropTable('{{%logs}}'); |
40
|
|
|
} |
41
|
|
|
} |
42
|
|
|
|