20220524085059_create_member_welfare_draw_table.php 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. use think\migration\Migrator;
  3. use think\migration\db\Column;
  4. class CreateMemberWelfareDrawTable extends Migrator
  5. {
  6. /**
  7. * Change Method.
  8. *
  9. * Write your reversible migrations using this method.
  10. *
  11. * More information on writing migrations is available here:
  12. * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
  13. *
  14. * The following commands can be used in this method and Phinx will
  15. * automatically reverse them when rolling back:
  16. *
  17. * createTable
  18. * renameTable
  19. * addColumn
  20. * renameColumn
  21. * addIndex
  22. * addForeignKey
  23. *
  24. * Remember to call "create()" or "update()" and NOT "save()" when working
  25. * with the Table class.
  26. */
  27. public function change()
  28. {
  29. $this->table('member_welfare_draw', array('id' => true, 'primary_key' => ['id'], 'engine' => 'InnoDB', 'comment' => '会员福利领取表'))
  30. ->addColumn('user_id', 'integer', array('limit' => 11, 'signed' => false, 'default' => 0, 'comment' => '用户ID'))
  31. ->addColumn('target_type', 'integer', array('limit' => 11, 'signed' => false, 'default' => 0, 'comment' => '来源类型 1会员专属优惠券 2异业合作券'))
  32. ->addColumn('target_id', 'integer',array('limit' => 10, 'signed' => false, 'default'=> 0,'comment'=>'来源ID'))
  33. ->addColumn('number', 'string',array('limit' => 255, 'default'=> '','comment'=>'福利编号'))
  34. ->addColumn('name', 'string',array('limit' => 255, 'default'=> '','comment'=>'福利名称'))
  35. ->addColumn('cost', 'decimal',array('limit' => 11,'precision'=>10,'scale'=>2,'signed'=>false,'default'=>0,'comment'=>'福利价值'))
  36. ->addColumn('amount', 'integer',array('limit' => 10, 'signed' => false, 'default'=> 0,'comment'=>'福利数量'))
  37. ->addColumn('start_time', 'date', array('limit' => 10,'signed' => false, 'default' => null, 'comment' => '发放开始时间'))
  38. ->addColumn('end_time', 'date', array('limit' => 10,'signed' => false, 'default' => null, 'comment' => '发放结束时间'))
  39. ->addColumn('use_start_time', 'date', array('limit' => 10,'null' => true, 'default' => null, 'comment' => '使用有效开始时间'))
  40. ->addColumn('use_end_time', 'date', array('limit' => 10,'null' => true,'default' => null, 'comment' => '使用有效结束时间'))
  41. ->addColumn('exchange_type', 'string', array('limit'=>255, 'default'=> '','comment'=>'兑换方式(target_type=2时需要) 1到店兑换 2线上兑换'))
  42. ->addColumn('position', 'integer',array('limit' => 10, 'signed' => false, 'default'=> 0,'comment'=>'坑位(exchange_type=2时需要),一个坑位代表一个具体的页面,支持配置这个页面链接的网址'))
  43. ->addColumn('url', 'string',array('limit' => 255, 'default'=> '','comment'=>'兑换链接(exchange_type=2时需要),填写合作平台的兑换网址'))
  44. ->addColumn('img', 'string',array('limit' => 255, 'default'=> '','comment'=>'背景图'))
  45. ->addColumn('code_id', 'integer',array('limit' => 10, 'signed' => false, 'default'=> 0,'comment'=>'兑换码ID'))
  46. ->addColumn('user_coupon_id', 'integer',array('limit' => 10, 'signed' => false, 'default'=> 0,'comment'=>'用户优惠券ID'))
  47. ->addColumn('check_status', 'integer', array('limit' => 4, 'signed' => false, 'default' => 0, 'comment' => '核销状态,0:未核销,1:已核销'))
  48. ->addColumn('use_status', 'integer', array('limit' => 4, 'signed' => false, 'default' => 0, 'comment' => '使用状态,0:未,1:已使用'))
  49. ->addColumn('create_time', 'integer', array('limit' => 10,'signed' => false, 'default' => 0, 'comment' => '创建时间'))
  50. ->addColumn('update_time', 'integer', array('limit' => 10,'signed' => false, 'default' => 0, 'comment' => '更新时间'))
  51. ->create();
  52. }
  53. }