M230904032353QimallAddonsAchievementFirstOrder.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace addons\Achievement\console\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M230904032353QimallAddonsAchievementFirstOrder
  6. */
  7. class M230904032353QimallAddonsAchievementFirstOrder extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. try {
  15. $table = 'qimall_addons_achievement_first_order';
  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_achievement_first_order` (
  20. `id` int(11) NOT NULL AUTO_INCREMENT,
  21. `mall_id` int(11) NOT NULL DEFAULT '0',
  22. `user_id` int(11) NOT NULL DEFAULT '0',
  23. `order_id` int(11) NOT NULL DEFAULT '0' COMMENT '订单id',
  24. `order_detail_id` int(11) NOT NULL COMMENT '订单详情id',
  25. `goods_id` int(11) NOT NULL DEFAULT '0' COMMENT '商品id',
  26. `created_at` int(11) NOT NULL DEFAULT '0',
  27. `updated_at` int(11) NOT NULL DEFAULT '0',
  28. `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
  29. PRIMARY KEY (`id`) USING BTREE,
  30. KEY `idx_mid_uid_gid` (`mall_id`,`user_id`,`goods_id`) USING BTREE
  31. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='业绩奖励升级商品首单记录';";
  32. $this->execute($sql);
  33. }catch (\Exception $e){
  34. }
  35. }
  36. /**
  37. * {@inheritdoc}
  38. */
  39. public function safeDown()
  40. {
  41. echo "M230904032353QimallAddonsAchievementFirstOrder cannot be reverted.\n";
  42. return false;
  43. }
  44. /*
  45. // Use up()/down() to run migration code without a transaction.
  46. public function up()
  47. {
  48. }
  49. public function down()
  50. {
  51. echo "M230904032353QimallAddonsAchievementFirstOrder cannot be reverted.\n";
  52. return false;
  53. }
  54. */
  55. }