20200619124302_wechat_users.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. use think\migration\Migrator;
  3. use think\migration\db\Column;
  4. class WechatUsers 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. $table = $this->table('wechat_users',array('engine'=>'Innodb', 'collation' => 'utf8mb4_general_ci', 'comment' => ' 微信用户表', 'signed' => false));
  30. $table->addColumn('nickname', 'string',array('limit' => 30,'default'=>'','comment'=>'用户名'))
  31. ->addColumn('avatar', 'string',array('limit' => 255,'comment'=>'用户头像'))
  32. ->addColumn('openid', 'string',array('limit' => 35, 'comment'=>'openid'))
  33. ->addColumn('language', 'string',array('limit' => 20, 'comment'=>'语言'))
  34. ->addColumn('country', 'string',array('limit' => 20, 'comment'=>'国家'))
  35. ->addColumn('province', 'string',array('limit' => 20, 'comment'=>'省份'))
  36. ->addColumn('city', 'string',array('limit' => 20, 'comment'=>'城市'))
  37. ->addColumn('subscribe', 'boolean',array('limit' => 1,'default'=> 1,'comment'=>'用户状态 0 取消订阅 1 订阅'))
  38. ->addColumn('block', 'boolean',array('limit' => 1,'default'=> 1,'comment'=>'拉黑状态 1 正常 2 拉黑'))
  39. ->addColumn('subscribe_time', 'integer',array('default'=>0,'comment'=>'订阅时间', 'signed' => false))
  40. ->addColumn('subscribe_scene', 'string', ['limit' => 50, 'comment' => '订阅场景 ADD_SCENE_SEARCH 公众号搜索,ADD_SCENE_ACCOUNT_MIGRATION 公众号迁移,ADD_SCENE_PROFILE_CARD 名片分享,ADD_SCENE_QR_CODE 扫描二维码,ADD_SCENE_PROFILE_LINK 图文页内名称点击,ADD_SCENE_PROFILE_ITEM 图文页右上角菜单,ADD_SCENE_PAID 支付后关注,ADD_SCENE_WECHAT_ADVERTISEMENT 微信广告,ADD_SCENE_OTHERS 其他'])
  41. ->addColumn('unionid', 'string', ['limit' => 255, 'comment' => '用户平台唯一身份认证'])
  42. ->addColumn('sex', 'boolean',array('limit' => 1,'default'=> 1,'comment'=>'用户状态 1 男 2 女 0 未知'))
  43. ->addColumn('remark', 'string', ['limit' => 255, 'comment' => '备注'])
  44. ->addColumn('groupid', 'integer', ['limit' => 0, 'comment' => '分组ID'])
  45. ->addColumn('tagid_list', 'string',['limit' => 50, 'default'=>0,'comment'=>'标签列表'])
  46. ->addColumn('created_at', 'integer', array('default'=>0,'comment'=>'创建时间', 'signed' => false ))
  47. ->addColumn('updated_at', 'integer', array('default'=>0,'comment'=>'更新时间', 'signed' => false))
  48. ->addColumn('deleted_at', 'integer', array('default'=>0,'comment'=>'删除状态,0未删除 >0 已删除', 'signed' => false))
  49. ->create();
  50. }
  51. }