1
0

20220708082554_create_train_class_cate.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. use think\migration\Migrator;
  3. use think\migration\db\Column;
  4. use app\model\Permission;
  5. class CreateTrainClassCate 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. $table = $this->table('train_class_cate')->setComment('课程培训分类');
  31. $table->addColumn('root_id', 'integer', ['limit' => 10, 'comment' => '店面id', 'null' => true, 'default' => 0])
  32. ->addColumn('name', 'string', ['limit' => 100, 'comment' => '分类名称', 'null' => true, 'default' => ''])
  33. ->addColumn('addtime', 'timestamp', ['comment' => '预约时间', 'default' => 'CURRENT_TIMESTAMP', 'null' => true])
  34. ->create();
  35. $this->table('train_class')
  36. ->addColumn('cate', 'string', ['limit' => 100, 'comment' => '分类名称', 'null' => true, 'default' => ''])
  37. ->update();
  38. $per = ',train/class_cate_edit,train/class_cate_add,train/class_cate,train/class_cate_list';
  39. $w[] = ['auth_name', '=', '课程培训'];
  40. $w[] = ['pid', '>', 0];
  41. $w[] = ['is_menu', '=', 1];
  42. $info = Permission::where($w)->find();
  43. $per = $info->relation . $per;
  44. $info->relation = $per;
  45. $info->save();
  46. }
  47. }