20220613100025_create_daily_tasks.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. use think\migration\Migrator;
  3. use think\migration\db\Column;
  4. use app\model\Permission;
  5. class CreateDailyTasks 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. $this->table('daily_tasks', ['comment' => '日常任务'])
  31. ->addColumn('root_id', 'integer', ['comment' => '企业id', 'limit'=>11,'default' => 0])
  32. ->addColumn('type', 'string', ['limit' => 255,'null' => true, 'default'=>'', 'comment'=>'类型'])
  33. ->addColumn('con_id', 'integer', ['comment' => '内容id', 'limit'=>11,'default' => 0])
  34. ->addColumn('org_ids', 'string', ['limit' => 255,'null' => true, 'default'=>'', 'comment'=>'指派组织id'])
  35. ->addColumn('addtime', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'comment' => '添加时间'])
  36. ->addColumn('end_date', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'comment' => '结束时间'])
  37. ->addColumn('del', 'integer', ['comment' => '删除', 'limit'=>11,'default' => 0])
  38. ->addColumn('employee_ids', 'text', ['comment'=> '完成人员id', 'null' => true,'default'=> null])
  39. ->addColumn('grawth', 'string', ['limit' => 255,'null' => true, 'default'=>'', 'comment'=>'完成率'])
  40. ->create();
  41. $q = ',dailyTasks/assign_org,dailyTasks/get_orgs,dailyTasks/get_person,dailyTasks/assign_org_edit,dailyTasks/del_assign,dailyTasks/save_date';
  42. $menu = Permission::where('auth_name','任务中心')->find();
  43. $menu->relation = $menu->relation.$q;
  44. $menu->save();
  45. }
  46. }