m150901_135806_addImportersFiles.php 1.06 KB
<?php

use yii\db\Schema;
use yii\db\Migration;

class m150901_135806_addImportersFiles extends Migration
{
    public function up()
    {
        $tableOptions = null;
        if ($this->db->driverName === 'mysql') {
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
        }

        $this->createTable('{{%importer_files}}', [
            'id' => $this->primaryKey(10)->notNull() . ' AUTO_INCREMENT',
            'importer_id' => 'int(6) unsigned NOT NULL',
            'upload_time' => 'timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP',
            'time_start' => 'timestamp NULL DEFAULT NULL',
            'time_end' => 'timestamp NULL DEFAULT NULL',
        ], $tableOptions);


        $this->createIndex('importer_id', '{{%importer_files}}', 'importer_id, time_start', false);
    }

    public function down()
    {
        $this->dropTable('{{%importer_files}}');
    }

    /*
    // Use safeUp/safeDown to run migration code within a transaction
    public function safeUp()
    {
    }

    public function safeDown()
    {
    }
    */
}