20220629025512_create_train_course_view.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. use think\migration\Migrator;
  3. use think\migration\db\Column;
  4. use app\model\Permission;
  5. class CreateTrainCourseView 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('train_course_view', ['comment' => '课件浏览记录'])
  31. ->addColumn('root_id', 'integer', ['comment' => '店面id', 'null' => true,'default'=>0])
  32. ->addColumn('employee_id', 'integer', ['comment' => '员工id','null' => true,'default'=>0])
  33. ->addColumn('uid', 'integer', ['comment' => '', 'null' => true,'default'=>0])
  34. ->addColumn('org_id', 'integer', ['comment' => '浏览时org_id','null' => true,'default'=>0])
  35. ->addColumn('con_id', 'integer', ['comment' => '浏览内容id', 'null' => true,'default'=>0])
  36. ->addColumn('type', 'string', ['limit'=> 255, 'comment'=> '浏览类型', 'default'=> '','null' => true])
  37. ->addColumn('time', 'integer', ['comment' => '浏览时长', 'null' => true,'default'=>0])
  38. ->addColumn('addtime', 'timestamp', ['default'=> 'CURRENT_TIMESTAMP','null' => true])
  39. ->create();
  40. $w[] = ['auth_name','=','课件管理'];
  41. $w[] = ['is_menu','=',1];
  42. $info = Permission::where($w)->find();
  43. $u['relation'] = $info->relation.',train/courese_view_list,train/courese_view';
  44. Permission::where($w)->update($u);
  45. }
  46. }