1 | CREATE TABLE IF NOT EXISTS `Module` (
|
---|
2 | `Id` int(11) NOT NULL auto_increment,
|
---|
3 | `Name` varchar(255) NOT NULL,
|
---|
4 | PRIMARY KEY (`Id`)
|
---|
5 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
---|
6 |
|
---|
7 |
|
---|
8 | CREATE TABLE IF NOT EXISTS `PermissionAssignment` (
|
---|
9 | `User` int(11) default NULL,
|
---|
10 | `Group` int(11) default NULL,
|
---|
11 | `Operation` int(11) default NULL,
|
---|
12 | `SubGroup` int(11) default NULL,
|
---|
13 | KEY `Group` (`Group`),
|
---|
14 | KEY `Operation` (`Operation`),
|
---|
15 | KEY `SubGroup` (`SubGroup`),
|
---|
16 | KEY `User` (`User`)
|
---|
17 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
---|
18 |
|
---|
19 |
|
---|
20 | CREATE TABLE IF NOT EXISTS `PermissionGroup` (
|
---|
21 | `Id` int(11) NOT NULL auto_increment,
|
---|
22 | `Name` varchar(255) NOT NULL,
|
---|
23 | PRIMARY KEY (`Id`)
|
---|
24 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
|
---|
25 |
|
---|
26 | CREATE TABLE IF NOT EXISTS `PermissionOperation` (
|
---|
27 | `Id` int(11) NOT NULL auto_increment,
|
---|
28 | `Module` int(11) NOT NULL,
|
---|
29 | `Action` varchar(255) NOT NULL,
|
---|
30 | `Item` int(11) NOT NULL,
|
---|
31 | PRIMARY KEY (`Id`),
|
---|
32 | KEY `Module` (`Module`),
|
---|
33 | KEY `Action` (`Action`)
|
---|
34 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
---|
35 |
|
---|
36 | ALTER TABLE `PermissionAssignment`
|
---|
37 | ADD CONSTRAINT `PermissionAssignment_ibfk_1` FOREIGN KEY (`Group`) REFERENCES `PermissionGroup` (`Id`),
|
---|
38 | ADD CONSTRAINT `PermissionAssignment_ibfk_2` FOREIGN KEY (`Operation`) REFERENCES `PermissionOperation` (`Id`),
|
---|
39 | ADD CONSTRAINT `PermissionAssignment_ibfk_3` FOREIGN KEY (`SubGroup`) REFERENCES `PermissionGroup` (`Id`),
|
---|
40 | ADD CONSTRAINT `PermissionAssignment_ibfk_4` FOREIGN KEY (`User`) REFERENCES `User` (`Id`);
|
---|
41 |
|
---|
42 | ALTER TABLE `PermissionOperation`
|
---|
43 | ADD CONSTRAINT `PermissionOperation_ibfk_1` FOREIGN KEY (`Module`) REFERENCES `Module` (`Id`);
|
---|
44 |
|
---|
45 |
|
---|
46 | ALTER TABLE `User` DROP `Role`;
|
---|