20220819123162_add_show_field.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. use think\migration\Migrator;
  3. use think\migration\db\Column;
  4. use app\model\Permission;
  5. class AddShowField 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_type')
  31. ->addColumn('show', 'integer',['limit' => 1,'comment'=>'类别是否展示,当类型为其它时不展示','default'=>0])
  32. ->update();
  33. $this->table('train_class_cate')
  34. ->addColumn('show', 'integer',['limit' => 1,'comment'=>'类别是否展示,当类型为其它时不展示','default'=>0])
  35. ->update();
  36. $this->table('talkskill_cates')
  37. ->addColumn('show', 'integer',['limit' => 1,'comment'=>'类别是否展示,当类型为其它时不展示','default'=>0])
  38. ->update();
  39. $this->table('talkskill_users_cate')
  40. ->addColumn('show', 'integer',['limit' => 1,'comment'=>'类别是否展示,当类型为其它时不展示','default'=>0])
  41. ->update();
  42. $train = Permission::where('id',39)->find();
  43. $train->relation = $train->relation . ',train/with_type_count,train/class_cate_or_label_del';
  44. $train->save();
  45. $exam = Permission::where('id',40)->find();
  46. $exam->relation = $exam->relation . ',exam/catedel';
  47. $exam->save();
  48. $talkskill = Permission::where('id',30)->find();
  49. $talkskill->relation = $talkskill->relation . ',talkskill/cate_del';
  50. $talkskill->save();
  51. }
  52. }