| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- namespace addons\CloudStock\console\migrations;
- use common\models\common\Addons;
- use yii\db\Migration;
- /**
- * Class M230915025002AlterQimallAddonsCloudStockGoods
- */
- class M230915025002AlterQimallAddonsCloudStockGoods extends Migration
- {
- /**
- * {@inheritdoc}
- */
- public function safeUp()
- {
- $sql ="ALTER TABLE qimall_addons_cloud_stock_goods add monthly_purchase text COMMENT '月限购';";
- $this->execute($sql);
- $sql ="ALTER TABLE qimall_addons_cloud_stock_goods add additional_purchase_restrictions text COMMENT '增加额外限购';";
- $this->execute($sql);
- $table = 'qimall_addons_cloud_stock_agent_guota';
- $sql="select * from information_schema.TABLES where TABLE_NAME = '{$table}';";
- $res = $this->db->createCommand($sql)->execute();
- if(empty($res)) {
- $sql="CREATE TABLE `qimall_addons_cloud_stock_agent_guota` (
- `id` bigint(20) NOT NULL AUTO_INCREMENT,
- `mall_id` int(11) NOT NULL DEFAULT '0' COMMENT '商城id',
- `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '用户id',
- `goods_id` int(11) NOT NULL COMMENT '商品id',
- `limit_nums` int(11) DEFAULT NULL COMMENT '增加额外限购数量',
- `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
- `created_at` bigint(20) NOT NULL DEFAULT '0',
- `updated_at` bigint(20) NOT NULL DEFAULT '0',
- PRIMARY KEY (`id`) USING BTREE,
- KEY `idx_mId_uId_gId` (`mall_id`,`user_id`,`goods_id`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='代理商额外限购表';";
- Addons::isInstall('CloudStock');
- $this->execute($sql);
- }
- }
- /**
- * {@inheritdoc}
- */
- public function safeDown()
- {
- echo "M230915025002AlterQimallAddonsCloudStockGoods cannot be reverted.\n";
- return false;
- }
- /*
- // Use up()/down() to run migration code without a transaction.
- public function up()
- {
- }
- public function down()
- {
- echo "M230915025002AlterQimallAddonsCloudStockGoods cannot be reverted.\n";
- return false;
- }
- */
- }
|