M230519034030QimallAddonsSignInUserPropertyAward.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace addons\SignIn\console\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M230519034030QimallAddonsSignInUserPropertyAward
  6. */
  7. class M230519034030QimallAddonsSignInUserPropertyAward extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. try {
  15. $table = 'qimall_addons_sign_in_user_property_award';
  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 = "
  20. CREATE TABLE `qimall_addons_sign_in_user_property_award` (
  21. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  22. `mall_id` int(11) NOT NULL DEFAULT '0',
  23. `user_id` int(11) NOT NULL DEFAULT '0',
  24. `give_type` varchar(255) NOT NULL DEFAULT '' COMMENT '奖励类型',
  25. `total_num` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '累计奖励数量',
  26. `status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
  27. `created_at` int(10) NOT NULL DEFAULT '0' COMMENT '创建时间',
  28. `updated_at` int(10) NOT NULL DEFAULT '0' COMMENT '更新时间',
  29. PRIMARY KEY (`id`) USING BTREE,
  30. KEY `user_mall_id` (`user_id`,`mall_id`) USING BTREE
  31. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户签到资产奖励汇总表';
  32. ";
  33. $this->execute($sql);
  34. }catch (\Exception $e){
  35. }
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. public function safeDown()
  41. {
  42. echo "M230519034030QimallAddonsSignInUserPropertyAward 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 "M230519034030QimallAddonsSignInUserPropertyAward cannot be reverted.\n";
  53. return false;
  54. }
  55. */
  56. }