M240826203048createQimallAddonsStoreGoodstrack.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace addons\Store\console\migrations;
  3. use addons\Store\common\models\StoreAdmin;
  4. use yii\db\Migration;
  5. /**
  6. * Class M240826203048CreateQimallAddonsStoretrack
  7. */
  8. class M240826203048CreateQimallAddonsStoreGoodstrack extends Migration
  9. {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public function safeUp()
  14. {
  15. $table = 'qimall_addons_store_goods_tracking';
  16. $sql="select * from information_schema.TABLES where TABLE_NAME = '{$table}';";
  17. $res = $this->db->createCommand($sql)->execute();
  18. if(!empty($res)) return '';
  19. $this->execute("CREATE TABLE `qimall_addons_store_goods_tracking` (
  20. `id` int(11) NOT NULL AUTO_INCREMENT,
  21. `mall_id` int(11) NOT NULL DEFAULT '0' COMMENT '商城ID',
  22. `store_id` int(11) NOT NULL DEFAULT '0' COMMENT '门店id',
  23. `goods_id` int(11) NOT NULL DEFAULT '0' COMMENT '商品id',
  24. `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '用户id',
  25. `browse_num` int(11) NOT NULL DEFAULT '0' COMMENT '浏览次数',
  26. `track_date` int(11) NOT NULL DEFAULT '0' COMMENT '日期,格式ymd[20240826]',
  27. `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[0禁用 1启用 -1删除]',
  28. `created_at` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
  29. `updated_at` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
  30. PRIMARY KEY (`id`),
  31. KEY `mall_id` (`mall_id`) USING BTREE,
  32. KEY `store_id` (`store_id`) USING BTREE,
  33. KEY `goods_id` (`goods_id`) USING BTREE,
  34. KEY `user_id` (`user_id`) USING BTREE
  35. ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='商城商品埋点表';");
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. public function safeDown()
  41. {
  42. echo "M240826203048CreateQimallAddonsStoretrack cannot be reverted.\n";
  43. return false;
  44. }
  45. /*
  46. // Use up()/down() to run migration code without a transaction.
  47. public function up()
  48. {
  49. }
  50. public function down()
  51. {
  52. echo "M240716083948AlterQimallAddonsStoreAdmin cannot be reverted.\n";
  53. return false;
  54. }
  55. */
  56. }