12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
- use think\migration\Migrator;
- use think\migration\db\Column;
- use app\model\Permission;
- class AddShowField extends Migrator
- {
- /**
- * Change Method.
- *
- * Write your reversible migrations using this method.
- *
- * More information on writing migrations is available here:
- * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
- *
- * The following commands can be used in this method and Phinx will
- * automatically reverse them when rolling back:
- *
- * createTable
- * renameTable
- * addColumn
- * renameColumn
- * addIndex
- * addForeignKey
- *
- * Remember to call "create()" or "update()" and NOT "save()" when working
- * with the Table class.
- */
- public function change()
- {
- $this->table('train_type')
- ->addColumn('show', 'integer',['limit' => 1,'comment'=>'类别是否展示,当类型为其它时不展示','default'=>0])
- ->update();
- $this->table('train_class_cate')
- ->addColumn('show', 'integer',['limit' => 1,'comment'=>'类别是否展示,当类型为其它时不展示','default'=>0])
- ->update();
- $this->table('talkskill_cates')
- ->addColumn('show', 'integer',['limit' => 1,'comment'=>'类别是否展示,当类型为其它时不展示','default'=>0])
- ->update();
- $this->table('talkskill_users_cate')
- ->addColumn('show', 'integer',['limit' => 1,'comment'=>'类别是否展示,当类型为其它时不展示','default'=>0])
- ->update();
- $train = Permission::where('id',39)->find();
- $train->relation = $train->relation . ',train/with_type_count,train/class_cate_or_label_del';
- $train->save();
- $exam = Permission::where('id',40)->find();
- $exam->relation = $exam->relation . ',exam/catedel';
- $exam->save();
- $talkskill = Permission::where('id',30)->find();
- $talkskill->relation = $talkskill->relation . ',talkskill/cate_del';
- $talkskill->save();
- }
- }
|