1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- use app\model\Permission;
- use think\migration\Migrator;
- use think\migration\db\Column;
- class CreateCustomerPackageTable 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('customer_package')
- ->addColumn('root_id', 'integer', ['comment' => '所属企业'])
- ->addColumn('name', 'string', ['comment' => '产品名', 'limit' => 50])
- ->addColumn('total_price', 'integer', ['comment' => '总价'])
- ->create();
- // 添加产品管理权限
- $p = Permission::where(['uri' => 'customerSetting/index'])->find();
- $relation = array_merge(explode(',', $p->relation), ['customerSetting/package', 'customerSetting/editPackage', 'customerSetting/delPackage']);
- $p->relation = implode(',', $relation);
- $p->save();
- }
- }
|