20191128114204_users.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. use think\migration\Migrator;
  3. use think\migration\db\Column;
  4. class Users 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('users', array('engine' => 'Innodb', 'comment' => '用户表', 'signed' => false));
  30. $table->addColumn('username', 'string', array('null' => true, 'limit' => 20, 'default' => '', 'comment' => '用户名'))
  31. ->addColumn('password', 'string', array('null' => true, 'limit' => 255, 'comment' => '用户密码'))
  32. ->addColumn('sex', 'integer', ['null' => true, 'default' => 0, 'comment' => '性别'])
  33. ->addColumn('email', 'string', array('null' => true, 'limit' => 100, 'comment' => '邮箱 登录'))
  34. ->addColumn('idcard', 'string', array('null' => true, 'limit' => 20, 'comment' => '身份证'))
  35. ->addColumn('user_no', 'string', array('null' => true, 'limit' => 20, 'comment' => '用户编号'))
  36. ->addColumn('department_id', 'integer', ['null' => true, 'default' => 0, 'comment' => '部门ID'])
  37. ->addColumn('status', 'boolean', array('null' => true, 'limit' => 1, 'default' => 1, 'comment' => '用户状态 1 正常 2 禁用'))
  38. ->addColumn('last_login_ip', 'string', array('null' => true, 'limit' => 50, 'default' => 0, 'comment' => '最后登录IP'))
  39. ->addColumn('last_login_time', 'integer', array('null' => true, 'default' => 0, 'comment' => '最后登录时间', 'signed' => false))
  40. ->addColumn('wxmp_open_id', 'string', ['limit' => '30', 'null' => true, 'signed' => true, 'comment' => '微信小程序openid',])
  41. ->addColumn('wx_open_id', 'string', ['limit' => '30', 'null' => true, 'signed' => true, 'comment' => '微信公众号openid',])
  42. ->addColumn('wx_union_id', 'string', ['limit' => '50', 'null' => true, 'signed' => true, 'comment' => '微信unionid',])
  43. ->addColumn('phone', 'string', ['null' => true, 'limit' => '20', 'null' => true, 'signed' => true, 'comment' => '手机号',])
  44. ->addColumn('remember_token', 'string', ['limit' => 512, 'default' => '', 'null' => true, 'comment' => '用户token'])
  45. ->addColumn('realname', 'string', ['null' => true, 'default' => '', 'comment' => '姓名', 'limit' => 20])
  46. ->addColumn('equ_password', 'string', array('null' => true, 'limit' => 255, 'comment' => '设备密码'))
  47. ->addColumn('avatar', 'string', ['limit' => 255, 'null' => true, 'default' => '', 'comment' => '用户头像', 'after' => 'email'])
  48. ->addColumn('creator_id', 'integer', ['null' => true, 'default' => 0, 'comment' => '创建人ID'])
  49. ->addColumn('created_at', 'integer', array('null' => true, 'default' => 0, 'comment' => '创建时间', 'signed' => false))
  50. ->addColumn('updated_at', 'integer', array('null' => true, 'default' => 0, 'comment' => '更新时间', 'signed' => false))
  51. ->addColumn('deleted_at', 'integer', array('null' => true, 'default' => 0, 'comment' => '删除状态,0未删除 >0 已删除', 'signed' => false))
  52. ->create();
  53. }
  54. }