db->createCommand($sql)->execute(); if(!empty($res)) return ''; $this->execute("CREATE TABLE `qimall_addons_store_tracking` ( `id` int(11) NOT NULL AUTO_INCREMENT, `mall_id` int(11) NOT NULL DEFAULT '0' COMMENT '商城ID', `store_id` int(11) NOT NULL DEFAULT '0' COMMENT '门店id', `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '用户id', `browse_num` int(11) NOT NULL DEFAULT '0' COMMENT '浏览次数', `track_date` int(11) NOT NULL DEFAULT '0' COMMENT '日期,格式ymd[20240826]', `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[0禁用 1启用 -1删除]', `created_at` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `updated_at` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', PRIMARY KEY (`id`), KEY `mall_id` (`mall_id`) USING BTREE, KEY `store_id` (`store_id`) USING BTREE, KEY `user_id` (`user_id`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='商城埋点表';"); // $this->createTable($table, [ // 'id' => $this->primaryKey(), // 'mall_id' => $this->integer()->notNull()->defaultValue(0)->comment('商城id'), // 'store_id' => $this->integer()->notNull()->defaultValue(0)->comment('门店id'), // 'user_id' => $this->integer()->notNull()->defaultValue(0)->comment('用户id'), // 'browse_num' => $this->integer()->notNull()->defaultValue(0)->comment('浏览次数'), // 'track_date' => $this->integer()->notNull()->defaultValue(0)->comment('日期,格式ymd[20240826]'), // 'status' => $this->integer()->notNull()->defaultValue(1)->comment('[0禁用 1启用 -1删除]'), // 'created_at' => $this->integer()->notNull()->defaultValue(0)->comment('创建时间'), // 'updated_at' => $this->integer()->notNull()->defaultValue(0)->comment('修改时间'), // ]); // // 添加索引 // // 创建复合索引 // $this->createIndex( // 'idx_mall_store_user', // 索引名称 // $table, // 表名 // ['mall_id', 'store_id', 'user_id'] // 要索引的列 // ); // // // 创建单列索引 // $this->createIndex( // 'idx_user_id', // 索引名称 // $table, // 表名 // 'user_id' // 要索引的列 // ); // $this->addCommentOnTable($table,'商城埋点表'); } /** * {@inheritdoc} */ public function safeDown() { echo "M240826203048CreateQimallAddonsStoretrack cannot be reverted.\n"; return false; } /* // Use up()/down() to run migration code without a transaction. public function up() { } public function down() { echo "M240716083948AlterQimallAddonsStoreAdmin cannot be reverted.\n"; return false; } */ }