diff --git a/backend/models/Importer.php b/backend/models/Importer.php new file mode 100644 index 0000000..d31fcea --- /dev/null +++ b/backend/models/Importer.php @@ -0,0 +1,92 @@ + 254], + [['PARSER_FIELD_SIGN'], 'string', 'max' => 1], + [['price_date_update'], 'string', 'max' => 15], + [['code'], 'unique'], + [['name'], 'unique'] + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => Yii::t('app', 'ID'), + 'code' => Yii::t('app', 'Code'), + 'name' => Yii::t('app', 'Name'), + 'name_price' => Yii::t('app', 'Name Price'), + 'currency_id' => Yii::t('app', 'Currency ID'), + 'delivery' => Yii::t('app', 'Delivery'), + 'email' => Yii::t('app', 'Email'), + 'info' => Yii::t('app', 'Info'), + 'active' => Yii::t('app', 'Active'), + 'PARSER_IS_ACTIVE' => Yii::t('app', 'Parser Is Active'), + 'PARSER_COLUMN_COUNT' => Yii::t('app', 'Parser Column Count'), + 'PARSER_FIELD_BRAND' => Yii::t('app', 'Parser Field Brand'), + 'PARSER_FIELD_ARTICLE' => Yii::t('app', 'Parser Field Article'), + 'PARSER_FIELD_ARTICLE_PREFIX' => Yii::t('app', 'Parser Field Article Prefix'), + 'PARSER_FIELD_PRICE' => Yii::t('app', 'Parser Field Price'), + 'PARSER_FIELD_DESCR' => Yii::t('app', 'Parser Field Descr'), + 'PARSER_FIELD_BOX' => Yii::t('app', 'Parser Field Box'), + 'PARSER_FIELD_ADD_BOX' => Yii::t('app', 'Parser Field Add Box'), + 'PARSER_FIELD_GROUP_RG' => Yii::t('app', 'Parser Field Group Rg'), + 'PARSER_FIELD_SIGN' => Yii::t('app', 'Parser Field Sign'), + 'PARSER_FIELD_MULTIPLIER' => Yii::t('app', 'Parser Field Multiplier'), + 'price_date_update' => Yii::t('app', 'Price Date Update'), + ]; + } +} diff --git a/console/migrations/m150831_130250_addImporters.php b/console/migrations/m150831_130250_addImporters.php new file mode 100644 index 0000000..a0bf8bd --- /dev/null +++ b/console/migrations/m150831_130250_addImporters.php @@ -0,0 +1,97 @@ +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', + '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}}'); + + return false; + } + + /* + // Use safeUp/safeDown to run migration code within a transaction + public function safeUp() + { + } + + public function safeDown() + { + } + */ +} -- libgit2 0.21.4