m150901_135806_addImportersFiles.php
1.06 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
<?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()
{
}
*/
}