1 | RENAME TABLE `measure` TO `Measure`
|
---|
2 | ALTER TABLE `Measure` ENGINE = InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
|
---|
3 |
|
---|
4 |
|
---|
5 | CREATE TABLE IF NOT EXISTS `User` (
|
---|
6 | `Id` int(11) NOT NULL auto_increment,
|
---|
7 | `Name` varchar(255) NOT NULL,
|
---|
8 | `Login` varchar(255) NOT NULL,
|
---|
9 | `Password` varchar(255) NOT NULL,
|
---|
10 | `Email` varchar(255) NOT NULL,
|
---|
11 | `LastIpAddress` varchar(16) NOT NULL,
|
---|
12 | `LastLoginTime` datetime NOT NULL,
|
---|
13 | `RegistrationTime` datetime NOT NULL,
|
---|
14 | `Locked` int(11) NOT NULL,
|
---|
15 | PRIMARY KEY (`Id`)
|
---|
16 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=11 ;
|
---|
17 |
|
---|
18 | INSERT INTO `User` (`Id`, `Name`, `Login`, `Password`, `Email`, `LastIpAddress`, `LastLoginTime`, `RegistrationTime`, `Locked`) VALUES
|
---|
19 | (10, 'Návštěvník', 'anonym', 'dasdsada', '', '', '2009-08-28 11:28:31', '2009-08-28 11:28:31', 0);
|
---|
20 |
|
---|
21 | CREATE TABLE IF NOT EXISTS `UserOnline` (
|
---|
22 | `Id` int(11) NOT NULL auto_increment,
|
---|
23 | `User` int(11) NOT NULL default '0',
|
---|
24 | `ActivityTime` datetime NOT NULL default '0000-00-00 00:00:00',
|
---|
25 | `LoginTime` datetime NOT NULL default '0000-00-00 00:00:00',
|
---|
26 | `SessionId` varchar(255) character set utf8 collate utf8_czech_ci NOT NULL default '',
|
---|
27 | `IpAddress` varchar(16) character set utf8 collate utf8_czech_ci NOT NULL default '',
|
---|
28 | `HostName` varchar(255) character set utf8 collate utf8_czech_ci NOT NULL default '',
|
---|
29 | `ScriptName` varchar(255) character set utf8 collate utf8_czech_ci NOT NULL,
|
---|
30 | PRIMARY KEY (`Id`),
|
---|
31 | KEY `User` (`User`)
|
---|
32 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
|
---|
33 |
|
---|
34 | ALTER TABLE `UserOnline`
|
---|
35 | ADD CONSTRAINT `UserOnline_ibfk_1` FOREIGN KEY (`User`) REFERENCES `User` (`Id`);
|
---|
36 |
|
---|
37 |
|
---|
38 | CREATE TABLE IF NOT EXISTS `Module` (
|
---|
39 | `Id` int(11) NOT NULL auto_increment,
|
---|
40 | `Name` varchar(255) NOT NULL,
|
---|
41 | PRIMARY KEY (`Id`)
|
---|
42 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
|
---|
43 |
|
---|
44 | CREATE TABLE IF NOT EXISTS `PermissionAssignment` (
|
---|
45 | `User` int(11) default NULL,
|
---|
46 | `Group` int(11) default NULL,
|
---|
47 | `Operation` int(11) default NULL,
|
---|
48 | `SubGroup` int(11) default NULL,
|
---|
49 | KEY `Group` (`Group`),
|
---|
50 | KEY `Action` (`Operation`),
|
---|
51 | KEY `SubGroup` (`SubGroup`),
|
---|
52 | KEY `User` (`User`)
|
---|
53 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
---|
54 |
|
---|
55 | CREATE TABLE IF NOT EXISTS `PermissionGroup` (
|
---|
56 | `Id` int(11) NOT NULL auto_increment,
|
---|
57 | `Name` varchar(255) NOT NULL,
|
---|
58 | PRIMARY KEY (`Id`)
|
---|
59 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
|
---|
60 |
|
---|
61 | CREATE TABLE IF NOT EXISTS `PermissionOperation` (
|
---|
62 | `Id` int(11) NOT NULL auto_increment,
|
---|
63 | `Module` int(11) NOT NULL,
|
---|
64 | `Action` varchar(255) NOT NULL,
|
---|
65 | `Item` int(11) NOT NULL,
|
---|
66 | PRIMARY KEY (`Id`),
|
---|
67 | KEY `Module` (`Module`),
|
---|
68 | KEY `Action` (`Action`)
|
---|
69 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
|
---|
70 |
|
---|
71 | ALTER TABLE `PermissionAssignment`
|
---|
72 | ADD CONSTRAINT `PermissionAssignment_ibfk_1` FOREIGN KEY (`Group`) REFERENCES `PermissionGroup` (`Id`),
|
---|
73 | ADD CONSTRAINT `PermissionAssignment_ibfk_3` FOREIGN KEY (`SubGroup`) REFERENCES `PermissionGroup` (`Id`),
|
---|
74 | ADD CONSTRAINT `PermissionAssignment_ibfk_4` FOREIGN KEY (`User`) REFERENCES `User` (`Id`),
|
---|
75 | ADD CONSTRAINT `PermissionAssignment_ibfk_5` FOREIGN KEY (`Operation`) REFERENCES `PermissionOperation` (`Id`);
|
---|
76 |
|
---|
77 | ALTER TABLE `PermissionOperation`
|
---|
78 | ADD CONSTRAINT `PermissionOperation_ibfk_1` FOREIGN KEY (`Module`) REFERENCES `Module` (`Id`);
|
---|
79 |
|
---|
80 | CREATE TABLE `MeasureGroup` (
|
---|
81 | `Id` INT NOT NULL AUTO_INCREMENT ,
|
---|
82 | `Name` VARCHAR( 255 ) NOT NULL ,
|
---|
83 | `Parent` INT NOT NULL ,
|
---|
84 | PRIMARY KEY ( `Id` )
|
---|
85 | ) ENGINE = InnoDB ;
|
---|
86 |
|
---|
87 | ALTER TABLE `MeasureGroup` ADD INDEX ( `Parent` );
|
---|
88 | ALTER TABLE `MeasureGroup` ADD FOREIGN KEY ( `Parent` ) REFERENCES `MeasureGroup` ( `Id` );
|
---|
89 | ALTER TABLE `MeasureGroup` CHANGE `Parent` `Parent` INT( 11 ) NULL ;
|
---|
90 |
|
---|
91 | ALTER TABLE `Measure` ADD `Group` INT NULL AFTER `Id` ;
|
---|
92 | ALTER TABLE `Measure` ADD INDEX ( `Group` ) ;
|
---|
93 | ALTER TABLE `Measure` ADD FOREIGN KEY ( `Group` ) REFERENCES `MeasureGroup` ( `Id` );
|
---|
94 | ALTER TABLE `Measure` DROP `OldName` ;
|
---|
95 | ALTER TABLE `Measure` DROP `PermissionView`, DROP `PermissionAdd`;
|
---|
96 |
|
---|
97 | ALTER TABLE `Measure` CHANGE `Name` `Name` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
|
---|
98 | CHANGE `Description` `Description` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
|
---|
99 | CHANGE `Info` `Info` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
|
---|
100 | CHANGE `DataTable` `DataTable` VARCHAR( 32 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'data',
|
---|
101 | CHANGE `DataType` `DataType` VARCHAR( 32 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
|
---|
102 |
|
---|