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