source: branches/mvc/SQL/Updates/40.sql

Last change on this file was 46, checked in by chronos, 10 years ago
  • Opraveno: SQL aktualizace 40 plus chybějící tabulka MeasureMethod.
  • Opraveno: Neplatné ukázkové konfigurační soubory.
File size: 4.3 KB
Line 
1RENAME TABLE `measure` TO `Measure`
2ALTER TABLE `Measure` ENGINE = InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
3
4
5CREATE 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
18INSERT 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
21CREATE 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
34ALTER TABLE `UserOnline`
35 ADD CONSTRAINT `UserOnline_ibfk_1` FOREIGN KEY (`User`) REFERENCES `User` (`Id`);
36
37
38CREATE 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
44CREATE 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
55CREATE 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
61CREATE 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
71ALTER 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
77ALTER TABLE `PermissionOperation`
78 ADD CONSTRAINT `PermissionOperation_ibfk_1` FOREIGN KEY (`Module`) REFERENCES `Module` (`Id`);
79
80CREATE TABLE `MeasureGroup` (
81`Id` INT NOT NULL AUTO_INCREMENT ,
82`Name` VARCHAR( 255 ) NOT NULL ,
83`Parent` INT NOT NULL ,
84PRIMARY KEY ( `Id` )
85) ENGINE = InnoDB ;
86
87ALTER TABLE `MeasureGroup` ADD INDEX ( `Parent` );
88ALTER TABLE `MeasureGroup` ADD FOREIGN KEY ( `Parent` ) REFERENCES `MeasureGroup` ( `Id` );
89ALTER TABLE `MeasureGroup` CHANGE `Parent` `Parent` INT( 11 ) NULL ;
90
91ALTER TABLE `Measure` ADD `Group` INT NULL AFTER `Id` ;
92ALTER TABLE `Measure` ADD INDEX ( `Group` ) ;
93ALTER TABLE `Measure` ADD FOREIGN KEY ( `Group` ) REFERENCES `MeasureGroup` ( `Id` );
94ALTER TABLE `Measure` DROP `OldName` ;
95ALTER TABLE `Measure` DROP `PermissionView`, DROP `PermissionAdd`;
96
97ALTER TABLE `Measure` CHANGE `Name` `Name` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
98CHANGE `Description` `Description` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
99CHANGE `Info` `Info` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
100CHANGE `DataTable` `DataTable` VARCHAR( 32 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'data',
101CHANGE `DataType` `DataType` VARCHAR( 32 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
102
Note: See TracBrowser for help on using the repository browser.