M230215021900AddQimallCommissionYearsBilling.php 2.1 KB

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