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