M230215021817AddQimallCommissionMonthBilling.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace app\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M230215021817AddQimallCommissionMonthBilling
  6. */
  7. class M230215021817AddQimallCommissionMonthBilling extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. try {
  15. $table = 'qimall_commission_month_billing';
  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_commission_month_billing` (
  20. `id` int(10) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  21. `mall_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '商城ID',
  22. `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '会员id',
  23. `month` varchar(255) NOT NULL DEFAULT '' COMMENT '月份',
  24. `expenditure_money` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '支出金额',
  25. `expenditure_nums` int(11) NOT NULL DEFAULT '0' COMMENT '支出笔数',
  26. `income_money` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '收入金额',
  27. `income_nums` int(11) NOT NULL DEFAULT '0' COMMENT '收入笔数',
  28. `status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用;]',
  29. `created_at` int(10) NOT NULL DEFAULT '0' COMMENT '创建时间',
  30. `updated_at` int(10) NOT NULL DEFAULT '0' COMMENT '上次更新数据时间',
  31. PRIMARY KEY (`id`) USING BTREE,
  32. KEY `mall_id` (`mall_id`) USING BTREE
  33. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='佣金月账单';";
  34. $this->execute($sql);
  35. } catch (\Exception $e) {
  36. }
  37. }
  38. /**
  39. * {@inheritdoc}
  40. */
  41. public function safeDown()
  42. {
  43. echo "M230215021817AddQimallCommissionMonthBilling cannot be reverted.\n";
  44. return false;
  45. }
  46. /*
  47. // Use up()/down() to run migration code without a transaction.
  48. public function up()
  49. {
  50. }
  51. public function down()
  52. {
  53. echo "M230215021817AddQimallCommissionMonthBilling cannot be reverted.\n";
  54. return false;
  55. }
  56. */
  57. }