add tables and updates for roles

This commit is contained in:
Uwe Steinmann 2016-02-24 14:34:30 +01:00
parent 480aca1c80
commit 4c3e45ee02
4 changed files with 100 additions and 9 deletions

View File

@ -50,6 +50,20 @@ CREATE TABLE `tblAttributeDefinitions` (
-- Table structure for table `tblUsers`
--
CREATE TABLE `tblRoles` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(50) default NULL,
`role` smallint(1) NOT NULL default '0',
PRIMARY KEY (`id`),
UNIQUE (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `tblUsers`
--
CREATE TABLE `tblUsers` (
`id` int(11) NOT NULL auto_increment,
`login` varchar(50) default NULL,
@ -59,7 +73,7 @@ CREATE TABLE `tblUsers` (
`language` varchar(32) NOT NULL,
`theme` varchar(32) NOT NULL,
`comment` text NOT NULL,
`role` smallint(1) NOT NULL default '0',
`role` int(11) NOT NULL,
`hidden` smallint(1) NOT NULL default '0',
`pwdExpiration` datetime NOT NULL default '0000-00-00 00:00:00',
`loginfailures` tinyint(4) NOT NULL default '0',
@ -67,7 +81,8 @@ CREATE TABLE `tblUsers` (
`quota` bigint,
`homefolder` int(11) default NULL,
PRIMARY KEY (`id`),
UNIQUE (`login`)
UNIQUE (`login`),
CONSTRAINT `tblUsers_role` FOREIGN KEY (`role`) REFERENCES `tblRoles` (`id`),
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
@ -598,7 +613,7 @@ CREATE TABLE `tblSessions` (
`theme` varchar(30) NOT NULL default '',
`language` varchar(30) NOT NULL default '',
`clipboard` text default '',
`su` INTEGER DEFAULT NULL,
`su` INTEGER DEFAULT NULL,
`splashmsg` text default '',
PRIMARY KEY (`id`),
CONSTRAINT `tblSessions_user` FOREIGN KEY (`userID`) REFERENCES `tblUsers` (`id`) ON DELETE CASCADE
@ -821,7 +836,7 @@ CREATE TABLE `tblTransmittals` (
CREATE TABLE `tblTransmittalItems` (
`id` int(11) NOT NULL auto_increment,
`transmittal` int(11) NOT NULL DEFAULT '0',
`transmittal` int(11) NOT NULL DEFAULT '0',
`document` int(11) default NULL,
`version` smallint(5) unsigned NOT NULL default '0',
`date` datetime,
@ -855,8 +870,10 @@ CREATE TABLE `tblCachedAccess` (
CREATE TABLE `tblAros` (
`id` int(11) NOT NULL auto_increment,
`parent` int(11),
`model` text NOT NULL,
`foreignid` int(11) NOT NULL DEFAULT '0',
`foreignid` int(11) NOT NULL DEFAULT '0',
`alias` varchar(255),
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@ -868,8 +885,10 @@ CREATE TABLE `tblAros` (
CREATE TABLE `tblAcos` (
`id` int(11) NOT NULL auto_increment,
`parent` int(11),
`model` text NOT NULL,
`foreignid` int(11) NOT NULL DEFAULT '0',
`foreignid` int(11) NOT NULL DEFAULT '0',
`alias` varchar(255),
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@ -881,8 +900,12 @@ CREATE TABLE `tblAcos` (
CREATE TABLE `tblArosAcos` (
`id` int(11) NOT NULL auto_increment,
`aro` int(11) NOT NULL DEFAULT '0',
`aco` int(11) NOT NULL DEFAULT '0',
`aro` int(11) NOT NULL DEFAULT '0',
`aco` int(11) NOT NULL DEFAULT '0',
`create` tinyint(4) NOT NULL DEFAULT '-1',
`read` tinyint(4) NOT NULL DEFAULT '-1',
`update` tinyint(4) NOT NULL DEFAULT '-1',
`delete` tinyint(4) NOT NULL DEFAULT '-1',
PRIMARY KEY (`id`),
UNIQUE (aco, aro),
CONSTRAINT `tblArosAcos_acos` FOREIGN KEY (`aco`) REFERENCES `tblAcos` (`id`) ON DELETE CASCADE,

View File

@ -47,6 +47,19 @@ CREATE TABLE `tblAttributeDefinitions` (
-- Table structure for table `tblUsers`
--
CREATE TABLE `tblRoles` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`name` varchar(50) default NULL,
`role` INTEGER NOT NULL default '0',
UNIQUE (`name`)
) ;
-- --------------------------------------------------------
--
-- Table structure for table `tblUsers`
--
CREATE TABLE `tblUsers` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`login` varchar(50) default NULL,
@ -56,7 +69,7 @@ CREATE TABLE `tblUsers` (
`language` varchar(32) NOT NULL,
`theme` varchar(32) NOT NULL,
`comment` text NOT NULL,
`role` INTEGER NOT NULL default '0',
`role` INTEGER NOT NULL REFERENCES `tblRoles` (`id`),
`hidden` INTEGER NOT NULL default '0',
`pwdExpiration` TEXT NOT NULL default '0000-00-00 00:00:00',
`loginfailures` INTEGER NOT NULL default '0',

View File

@ -73,6 +73,44 @@ CREATE TABLE `tblTransmittalItems` (
UNIQUE (document, version)
);
CREATE TABLE `tblRoles` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`name` varchar(50) default NULL,
`role` INTEGER NOT NULL default '0',
UNIQUE (`name`)
);
INSERT INTO `tblRoles` (`id`, `name`, `role`) VALUES (1, 'Admin', 1);
INSERT INTO `tblRoles` (`id`, `name`, `role`) VALUES (2, 'Guest', 2);
INSERT INTO `tblRoles` (`id`, `name`, `role`) VALUES (3, 'User', 0);
UPDATE `tblUsers` SET role=3 WHERE role=0;
CREATE TABLE `new_tblUsers` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`login` varchar(50) default NULL,
`pwd` varchar(50) default NULL,
`fullName` varchar(100) default NULL,
`email` varchar(70) default NULL,
`language` varchar(32) NOT NULL,
`theme` varchar(32) NOT NULL,
`comment` text NOT NULL,
`role` INTEGER NOT NULL REFERENCES `tblRoles` (`id`),
`hidden` INTEGER NOT NULL default '0',
`pwdExpiration` TEXT NOT NULL default '0000-00-00 00:00:00',
`loginfailures` INTEGER NOT NULL default '0',
`disabled` INTEGER NOT NULL default '0',
`quota` INTEGER,
`homefolder` INTEGER default NULL REFERENCES `tblFolders` (`id`),
UNIQUE (`login`)
);
INSERT INTO new_tblUsers SELECT * FROM tblUsers;
DROP TABLE tblUsers;
ALTER TABLE new_tblUsers RENAME TO tblUsers;
UPDATE tblVersion set major=5, minor=1, subminor=0;
COMMIT;

View File

@ -94,6 +94,23 @@ CREATE TABLE `tblTransmittalItems` (
CONSTRAINT `tblTransmittalItem_transmittal` FOREIGN KEY (`transmittal`) REFERENCES `tblTransmittals` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `tblRoles` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(50) default NULL,
`role` smallint(1) NOT NULL default '0',
PRIMARY KEY (`id`),
UNIQUE (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `tblRoles` (`id`, `name`, `role`) VALUES (1, 'Admin', 1);
INSERT INTO `tblRoles` (`id`, `name`, `role`) VALUES (2, 'Guest', 2);
INSERT INTO `tblRoles` (`id`, `name`, `role`) VALUES (3, 'User', 0);
ALTER TABLE `tblRoles` AUTO_INCREMENT=4;
ALTER TABLE tblUsers CHANGE role role int(11) NOT NULL;
UPDATE `tblUsers` SET role=3 WHERE role=0;
ALTER TABLE tblUsers ADD CONSTRAINT `tblUsers_role` FOREIGN KEY (`role`) REFERENCES `tblRoles` (`id`);
UPDATE tblVersion set major=5, minor=1, subminor=0;
COMMIT;