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