|
1 | 1 | <?php |
2 | 2 |
|
3 | 3 | use think\migration\Migrator; |
4 | | -use think\migration\db\Column; |
5 | 4 |
|
6 | 5 | class Permission extends Migrator |
7 | 6 | { |
@@ -31,36 +30,36 @@ public function change() |
31 | 30 | $tables = config('permission.tables'); |
32 | 31 |
|
33 | 32 | // 规则表 |
34 | | - $table = $this->table($tables['permission'], array('engine'=>'MyISAM')); |
35 | | - $table->addColumn('name', 'string', array('limit' => 100,'comment'=>'规则名称')) |
36 | | - ->addIndex(array('name'), array('unique' => true)) |
| 33 | + $table = $this->table($tables['permission'], ['engine'=>'MyISAM']); |
| 34 | + $table->addColumn('name', 'string', ['limit' => 100, 'comment'=>'规则名称']) |
| 35 | + ->addIndex(['name'], ['unique' => true]) |
37 | 36 | ->create(); |
38 | 37 |
|
39 | 38 | // 角色表 |
40 | | - $table = $this->table($tables['role'], array('engine'=>'MyISAM')); |
41 | | - $table->addColumn('name', 'string', array('limit' => 100,'comment'=>'角色名称')) |
42 | | - ->addIndex(array('name'), array('unique' => true)) |
| 39 | + $table = $this->table($tables['role'], ['engine'=>'MyISAM']); |
| 40 | + $table->addColumn('name', 'string', ['limit' => 100, 'comment'=>'角色名称']) |
| 41 | + ->addIndex(['name'], ['unique' => true]) |
43 | 42 | ->create(); |
44 | 43 |
|
45 | 44 | // 角色与规则 多对多中间表 |
46 | | - $table = $this->table($tables['role_permission_access'], array('engine'=>'MyISAM')); |
47 | | - $table->addColumn('role_id', 'integer', array('comment'=>'角色主键')) |
48 | | - ->addColumn('permission_id', 'integer', array('comment'=>'规则主键')) |
49 | | - ->addIndex(array('permission_id', 'role_id'), array('unique' => true)) |
| 45 | + $table = $this->table($tables['role_permission_access'], ['engine'=>'MyISAM']); |
| 46 | + $table->addColumn('role_id', 'integer', ['comment'=>'角色主键']) |
| 47 | + ->addColumn('permission_id', 'integer', ['comment'=>'规则主键']) |
| 48 | + ->addIndex(['permission_id', 'role_id'], ['unique' => true]) |
50 | 49 | ->create(); |
51 | | - |
| 50 | + |
52 | 51 | // 角色与用户 多对多中间表 |
53 | | - $table = $this->table($tables['user_role_access'], array('engine'=>'MyISAM')); |
54 | | - $table->addColumn('user_id', 'integer', array('comment'=>'用户id')) |
55 | | - ->addColumn('role_id', 'integer', array('comment'=>'角色id')) |
56 | | - ->addIndex(array('user_id', 'role_id'), array('unique' => true)) |
| 52 | + $table = $this->table($tables['user_role_access'], ['engine'=>'MyISAM']); |
| 53 | + $table->addColumn('user_id', 'integer', ['comment'=>'用户id']) |
| 54 | + ->addColumn('role_id', 'integer', ['comment'=>'角色id']) |
| 55 | + ->addIndex(['user_id', 'role_id'], ['unique' => true]) |
57 | 56 | ->create(); |
58 | | - |
| 57 | + |
59 | 58 | // 多态关联(用户与角色中间表) |
60 | | - $table = $this->table($tables['has_permission'], array('engine'=>'MyISAM')); |
61 | | - $table->addColumn('content', 'string', array('limit' => 50)) |
62 | | - ->addColumn('model_id', 'integer', array('comment'=>'模型主键')) |
63 | | - ->addColumn('model_type', 'string', array('limit' => 50,'comment'=>'模型命名空间')) |
| 59 | + $table = $this->table($tables['has_permission'], ['engine'=>'MyISAM']); |
| 60 | + $table->addColumn('content', 'string', ['limit' => 50]) |
| 61 | + ->addColumn('model_id', 'integer', ['comment'=>'模型主键']) |
| 62 | + ->addColumn('model_type', 'string', ['limit' => 50, 'comment'=>'模型命名空间']) |
64 | 63 | ->create(); |
65 | 64 | } |
66 | 65 | } |
0 commit comments