20221001082202_create_activity_sign.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. use think\migration\Migrator;
  3. use think\migration\db\Column;
  4. use app\model\Permission;
  5. class CreateActivitySign extends Migrator
  6. {
  7. /**
  8. * Change Method.
  9. *
  10. * Write your reversible migrations using this method.
  11. *
  12. * More information on writing migrations is available here:
  13. * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
  14. *
  15. * The following commands can be used in this method and Phinx will
  16. * automatically reverse them when rolling back:
  17. *
  18. * createTable
  19. * renameTable
  20. * addColumn
  21. * renameColumn
  22. * addIndex
  23. * addForeignKey
  24. *
  25. * Remember to call "create()" or "update()" and NOT "save()" when working
  26. * with the Table class.
  27. */
  28. public function change()
  29. {
  30. //活动报名生成二维码表
  31. $table = $this->table('activity_sign', ['comment' => '活动报名表', 'engine'=>'InnoDB']);
  32. $table->addColumn('uid', 'integer',array('comment'=>'客户id','default'=> 0))
  33. ->addColumn('root_id', 'integer',array('comment'=>'店面id','default'=> 0))
  34. ->addColumn('aid', 'integer',array('comment'=>'活动id','default'=> 0))
  35. ->addColumn('share_uid', 'integer',array('comment'=>'分享人uid','default'=> 0))
  36. ->addColumn('share_employee_id', 'integer',array('comment'=>'分享人业务员id','default'=> 0))
  37. ->addColumn('qrcode', 'string', ['limit' => 255, 'comment' => '报名二维码', 'null' => true, 'default' => ''])
  38. ->addColumn('qrcode_con', 'string', ['limit' => 255, 'comment' => '二维码内容', 'null' => true, 'default' => ''])
  39. ->addColumn('qrcode_status', 'integer',array('comment'=>'是否扫码','default'=> 0))
  40. ->addColumn('addtime', 'timestamp',array('comment'=>'添加时间','default'=> 'CURRENT_TIMESTAMP'))
  41. ->create();
  42. //员工管理增加是否是扫码人员
  43. $this->table('employee')
  44. ->addColumn('code_scanning_personnel', 'integer', ['comment' => '是否是活动扫码人员 0否,1是', 'default' => 0])
  45. ->update();
  46. //添加权限
  47. $per3 = ',employee/codeScanning';
  48. $w3[] = ['auth_name', '=', '员工管理'];
  49. $info3 = Permission::where($w3)->find();
  50. $per3 = $info3->relation . $per3;
  51. $info3->relation = $per3;
  52. $info3->save();
  53. }
  54. }