@@ -32,27 +32,35 @@ public function change()
3232
3333 // 规则表
3434 $ table = $ this ->table ($ tables ['permission ' ], array ('engine ' =>'MyISAM ' ));
35- $ table ->addColumn ('name ' , 'string ' , array ('limit ' => 100 ,'default ' => '' , ' comment ' =>'规则名称 ' ))
35+ $ table ->addColumn ('name ' , 'string ' , array ('limit ' => 100 ,'comment ' =>'规则名称 ' ))
3636 ->addIndex (array ('name ' ), array ('unique ' => true ))
3737 ->create ();
3838
39- // 角色
39+ // 角色表
4040 $ table = $ this ->table ($ tables ['role ' ], array ('engine ' =>'MyISAM ' ));
41- $ table ->addColumn ('name ' , 'string ' , array ('limit ' => 100 ,'default ' => '' , ' comment ' =>'角色名称 ' ))
41+ $ table ->addColumn ('name ' , 'string ' , array ('limit ' => 100 ,'comment ' =>'角色名称 ' ))
4242 ->addIndex (array ('name ' ), array ('unique ' => true ))
4343 ->create ();
44+
45+ // 角色与规则 多对多中间表
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 ))
50+ ->create ();
4451
45- // 中间表
46- $ table = $ this ->table ($ tables ['role_access ' ], array ('engine ' =>'MyISAM ' ));
47- $ table ->addColumn ('user_id ' , 'integer ' , array ('limit ' => 11 ,'comment ' =>'用户id ' ))
48- ->addColumn ('role_id ' , 'integer ' , array ('limit ' => 11 ,'comment ' =>'角色id ' ))
52+ // 角色与用户 多对多中间表
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 ))
4957 ->create ();
5058
5159 // 多态关联(用户与角色中间表)
5260 $ table = $ this ->table ($ tables ['has_permission ' ], array ('engine ' =>'MyISAM ' ));
53- $ table ->addColumn ('content ' , 'string ' , array ('limit ' => 50 , ' default ' => '' , ' comment ' => '' ))
54- ->addColumn ('model_id ' , 'integer ' , array ('limit ' => 11 , ' comment ' =>'' ))
55- ->addColumn ('model_type ' , 'string ' , array ('limit ' => 50 ,'default ' => '' , ' comment ' =>'' ))
61+ $ table ->addColumn ('content ' , 'string ' , array ('limit ' => 50 ))
62+ ->addColumn ('model_id ' , 'integer ' , array ('comment ' =>'模型主键 ' ))
63+ ->addColumn ('model_type ' , 'string ' , array ('limit ' => 50 ,'comment ' =>'模型命名空间 ' ))
5664 ->create ();
5765 }
5866}
0 commit comments