m220227_143428_member_credits_log.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. use yii\db\Migration;
  3. class m220227_143428_member_credits_log extends Migration
  4. {
  5. public function up()
  6. {
  7. /* 取消外键约束 */
  8. $this->execute('SET foreign_key_checks = 0');
  9. /* 创建表 */
  10. $this->createTable('{{%member_credits_log}}', [
  11. 'id' => "int(10) NOT NULL AUTO_INCREMENT",
  12. 'app_id' => "varchar(50) NULL DEFAULT '' COMMENT '应用id'",
  13. 'merchant_id' => "int(10) unsigned NULL DEFAULT '0' COMMENT '商户id'",
  14. 'store_id' => "int(10) unsigned NULL DEFAULT '0' COMMENT '店铺ID'",
  15. 'member_id' => "int(11) unsigned NULL DEFAULT '0' COMMENT '用户id'",
  16. 'member_type' => "tinyint(4) NULL DEFAULT '1' COMMENT '1:会员;2:后台管理员;3:商家管理员'",
  17. 'pay_type' => "tinyint(4) NULL DEFAULT '0' COMMENT '支付类型'",
  18. 'type' => "varchar(50) NOT NULL DEFAULT '' COMMENT '变动类型[integral:积分;money:余额]'",
  19. 'group' => "varchar(50) NULL DEFAULT '' COMMENT '变动的组别'",
  20. 'old_num' => "decimal(10,2) NULL DEFAULT '0.00' COMMENT '之前的数据'",
  21. 'new_num' => "decimal(10,2) NULL DEFAULT '0.00' COMMENT '变动后的数据'",
  22. 'num' => "decimal(10,2) NULL DEFAULT '0.00' COMMENT '变动的数据'",
  23. 'remark' => "varchar(200) NULL DEFAULT '' COMMENT '备注'",
  24. 'ip' => "varchar(50) NULL DEFAULT '' COMMENT 'ip地址'",
  25. 'map_id' => "int(10) NULL DEFAULT '0' COMMENT '关联id'",
  26. 'is_addon' => "tinyint(4) unsigned NULL DEFAULT '0' COMMENT '是否插件'",
  27. 'addon_name' => "varchar(200) NULL DEFAULT '' COMMENT '插件名称'",
  28. 'status' => "tinyint(4) NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]'",
  29. 'created_at' => "int(10) unsigned NULL DEFAULT '0' COMMENT '创建时间'",
  30. 'updated_at' => "int(10) unsigned NULL DEFAULT '0' COMMENT '修改时间'",
  31. 'PRIMARY KEY (`id`)'
  32. ], "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='会员_积分等变动表'");
  33. /* 索引设置 */
  34. $this->createIndex('member_id','{{%member_credits_log}}','member_id',0);
  35. $this->createIndex('member_type','{{%member_credits_log}}','member_type, status',0);
  36. /* 表数据 */
  37. /* 设置外键约束 */
  38. $this->execute('SET foreign_key_checks = 1;');
  39. }
  40. public function down()
  41. {
  42. $this->execute('SET foreign_key_checks = 0');
  43. /* 删除表 */
  44. $this->dropTable('{{%member_credits_log}}');
  45. $this->execute('SET foreign_key_checks = 1;');
  46. }
  47. }
粤ICP备19079148号