m151203_134605_addLogTable.php
1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
use yii\db\Schema;
use yii\db\Migration;
class m151203_134605_addLogTable extends Migration
{
    public function up()
    {
        $table = <<< MySQL
            CREATE TABLE `w_log` (
            `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
            `error` BOOL NOT NULL DEFAULT FALSE,
            `record_type` int(1) unsigned NOT NULL DEFAULT 1,
            `time_start` timestamp NULL DEFAULT NULL,
            `importer_id` int(6) unsigned NOT NULL,
            `time_end` timestamp NOT NULL  DEFAULT CURRENT_TIMESTAMP,
            `log_msg` MEDIUMTEXT,
            `file_name` VARCHAR(100),
            PRIMARY KEY (`id`),
            KEY `record_type` (`error`,`record_type`),
            KEY `time_start` (`time_start`)
            ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
MySQL;
        $this->execute($table);
    }
    public function down()
    {
        // вернем все как было
        $drop_table = 'drop table if exists w_log';
        $this->execute($drop_table);
    }
    /*
    // Use safeUp/safeDown to run migration code within a transaction
    public function safeUp()
    {
    }
    public function safeDown()
    {
    }
    */
}