From e8db28d9946037ade1ac023b973afd705dfbbbfc Mon Sep 17 00:00:00 2001 From: Mihail Date: Tue, 1 Sep 2015 17:33:57 +0300 Subject: [PATCH] migration files for importer_files and importer_prefix tables --- console/migrations/m150831_130250_addImporters.php | 35 ----------------------------------- console/migrations/m150901_135806_addImportersFiles.php | 42 ++++++++++++++++++++++++++++++++++++++++++ console/migrations/m150901_141850_addImportersPrefix.php | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 35 deletions(-) create mode 100644 console/migrations/m150901_135806_addImportersFiles.php create mode 100644 console/migrations/m150901_141850_addImportersPrefix.php diff --git a/console/migrations/m150831_130250_addImporters.php b/console/migrations/m150831_130250_addImporters.php index a0bf8bd..2fbc121 100644 --- a/console/migrations/m150831_130250_addImporters.php +++ b/console/migrations/m150831_130250_addImporters.php @@ -9,43 +9,9 @@ class m150831_130250_addImporters extends Migration { $tableOptions = null; if ($this->db->driverName === 'mysql') { - // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB'; } -// 'userid' => Schema::TYPE_PK . ' AUTO_INCREMENT', -// 'email' => Schema::TYPE_STRING . '(45) NOT NULL', -// 'name' => Schema::TYPE_STRING . '(100) NOT NULL', -// -// CREATE TABLE 'w_importers' ( -// 'id' int(6) unsigned NOT NULL 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 DEFAULT '', -// 'PARSER_FIELD_MULTIPLIER' float(8,2) unsigned DEFAULT NULL, -// 'price_date_update' varchar(15) NOT NULL, -// PRIMARY KEY ('id'), -// UNIQUE KEY 'code' ('code'), -// UNIQUE KEY 'name' ('name'), -// KEY 'active' ('active') -// ) ENGINE=InnoDB DEFAULT CHARSET=utf8 - $this->createTable('{{%importer}}', [ 'id' => $this->primaryKey(6)->notNull() . ' AUTO_INCREMENT', 'code' =>'varchar(254) NOT NULL', @@ -81,7 +47,6 @@ class m150831_130250_addImporters extends Migration { $this->dropTable('{{%importer}}'); - return false; } /* diff --git a/console/migrations/m150901_135806_addImportersFiles.php b/console/migrations/m150901_135806_addImportersFiles.php new file mode 100644 index 0000000..647e773 --- /dev/null +++ b/console/migrations/m150901_135806_addImportersFiles.php @@ -0,0 +1,42 @@ +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() + { + } + */ +} diff --git a/console/migrations/m150901_141850_addImportersPrefix.php b/console/migrations/m150901_141850_addImportersPrefix.php new file mode 100644 index 0000000..a59f15a --- /dev/null +++ b/console/migrations/m150901_141850_addImportersPrefix.php @@ -0,0 +1,41 @@ +db->driverName === 'mysql') { + $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB'; + } + + $this->createTable('{{%importer_prefix}}', [ + 'id' => $this->primaryKey(10)->notNull() . ' AUTO_INCREMENT', + 'importer_id' => 'int(6) unsigned NOT NULL', + 'brand' => 'varchar(100) NOT NULL', + 'prefix' => 'varchar(50) NOT NULL', + 'timestamp' => 'timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP', + ], $tableOptions); + + $this->createIndex('importer_id', '{{%importer_prefix}}', 'importer_id, brand, prefix', true); + } + + public function down() + { + $this->dropTable('{{%importer_prefix}}'); + } + + /* + // Use safeUp/safeDown to run migration code within a transaction + public function safeUp() + { + } + + public function safeDown() + { + } + */ +} -- libgit2 0.21.4