M230717100142QimallAddonsCloudStockBonusPoolUser.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace addons\CloudStock\console\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M230717100142QimallAddonsCloudStockBonusPoolUser
  6. */
  7. class M230717100142QimallAddonsCloudStockBonusPoolUser extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. try {
  15. $table = 'qimall_addons_cloud_stock_bonus_pool_user';
  16. $sql="select * from information_schema.TABLES where TABLE_NAME = '{$table}';";
  17. $res = $this->db->createCommand($sql)->execute();
  18. if(!empty($res)) return '';
  19. $sql="CREATE TABLE `qimall_addons_cloud_stock_bonus_pool_user` (
  20. `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  21. `mall_id` int(10) NOT NULL DEFAULT '0' COMMENT '商城ID',
  22. `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
  23. `level` int(10) NOT NULL DEFAULT '0' COMMENT '等级(权重)',
  24. `pool_income` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '分红池总收益,单位:元',
  25. `upgrade_status` smallint(6) NOT NULL DEFAULT '0' COMMENT '1条件升级,2购买指定商品升级,3手动升级',
  26. `upgrade_level_at` int(10) NOT NULL DEFAULT '0' COMMENT '等级升级时间',
  27. `status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
  28. `created_at` bigint(20) DEFAULT '0' COMMENT '创建时间',
  29. `updated_at` bigint(20) DEFAULT '0' COMMENT '更新时间',
  30. PRIMARY KEY (`id`) USING BTREE,
  31. KEY `mall_user_id_level` (`mall_id`,`user_id`,`level`) USING BTREE
  32. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='云库存分红池用户';";
  33. $this->execute($sql);
  34. }catch (\Exception $e){
  35. }
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. public function safeDown()
  41. {
  42. echo "M230717100142QimallAddonsCloudStockBonusPoolUser 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 "M230717100142QimallAddonsCloudStockBonusPoolUser cannot be reverted.\n";
  53. return false;
  54. }
  55. */
  56. }