m150831_130250_addImporters.php
2.25 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
use yii\db\Schema;
use yii\db\Migration;
class m150831_130250_addImporters 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}}', [
            'id' => $this->primaryKey(6)->notNull() .  ' AUTO_INCREMENT',
               'code' =>'varchar(254) NOT NULL',
               'name' => 'varchar(254) NOT NULL',
               'name_price' => 'varchar(254) NOT NULL',
               'currency_id' => 'int(3) unsigned NOT NULL',
               'delivery' => 'varchar(254) NOT NULL',
               'email' => 'varchar(254) NOT NULL',
               'info' => 'text NOT NULL',
               'active' => 'tinyint(1) unsigned NOT NULL DEFAULT 1',
               'PARSER_IS_ACTIVE' => 'tinyint(1) unsigned NOT NULL DEFAULT 0',
               'PARSER_COLUMN_COUNT' => 'int(6) unsigned DEFAULT NULL',
               'PARSER_FIELD_BRAND' => 'int(3) unsigned DEFAULT NULL',
               'PARSER_FIELD_ARTICLE' => 'int(3) unsigned DEFAULT NULL',
               'PARSER_FIELD_ARTICLE_PREFIX' => 'tinyint(1) unsigned NOT NULL DEFAULT 0',
               'PARSER_FIELD_PRICE' => 'int(3) unsigned DEFAULT NULL',
               'PARSER_FIELD_DESCR'  =>'int(3) unsigned DEFAULT NULL',
               'PARSER_FIELD_BOX' => 'int(3) unsigned DEFAULT NULL',
               'PARSER_FIELD_ADD_BOX' => 'int(3) unsigned DEFAULT NULL',
               'PARSER_FIELD_GROUP_RG' => 'int(3) unsigned DEFAULT NULL',
               'PARSER_FIELD_SIGN' => 'varchar(1) NOT NULL',
               'PARSER_FIELD_MULTIPLIER' => 'float(8,2) unsigned DEFAULT NULL',
               'price_date_update' => 'varchar(15) NOT NULL'
        ], $tableOptions);
        $this->createIndex('code', '{{%importer}}', 'code', true);
        $this->createIndex('name', '{{%importer}}', 'name', true);
        $this->createIndex('active', '{{%importer}}', 'active', false);
    }
    public function down()
    {
        $this->dropTable('{{%importer}}');
    }
    /*
    // Use safeUp/safeDown to run migration code within a transaction
    public function safeUp()
    {
    }
    public function safeDown()
    {
    }
    */
}