m151203_134605_addLogTable.php 1.18 KB
<?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()
    {
    }
    */
}