M230406095623QimallAddonsDistributionUpgradeCount.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace addons\Distribution\console\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M230406095623QimallAddonsDistributionUpgradeCount
  6. */
  7. class M230406095623QimallAddonsDistributionUpgradeCount extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. try {
  15. $table = 'qimall_addons_distribution_upgrade_count';
  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_distribution_upgrade_count` (
  20. `id` int(10) NOT NULL AUTO_INCREMENT,
  21. `mall_id` int(10) DEFAULT '0' COMMENT '商城ID',
  22. `user_id` int(10) DEFAULT '0' COMMENT '服务商ID',
  23. `direct_num` int(10) DEFAULT '0' COMMENT '好友人数',
  24. `achievement` decimal(12,2) DEFAULT '0.00' COMMENT '服务商团队业绩,单位:元',
  25. `status` tinyint(4) DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
  26. `created_at` int(10) DEFAULT '0' COMMENT '创建时间',
  27. `updated_at` int(10) DEFAULT '0' COMMENT '修改时间',
  28. PRIMARY KEY (`id`) USING BTREE,
  29. KEY `user_id` (`user_id`) USING BTREE
  30. ) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='分销商团队业绩统计表';
  31. ";
  32. $this->execute($sql);
  33. } catch (\Exception $e) {
  34. }
  35. }
  36. /**
  37. * {@inheritdoc}
  38. */
  39. public function safeDown()
  40. {
  41. echo "M230406095623QimallAddonsDistributionUpgradeCount 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 "M230406095623QimallAddonsDistributionUpgradeCount cannot be reverted.\n";
  52. return false;
  53. }
  54. */
  55. }