Ticket #263: Schema changes.

This commit is contained in:
James Muehlner
2013-07-18 22:13:09 -07:00
parent ea36b4f556
commit 012cd6c8b4
3 changed files with 120 additions and 5 deletions

View File

@@ -1,17 +1,42 @@
--
-- Table of connection groups. Each connection group has a name.
--
CREATE TABLE `guacamole_connection_group` (
`connection_group_id` int(11) NOT NULL AUTO_INCREMENT,
`parent_group_id` int(11),
`connection_group_name` varchar(128) NOT NULL,
PRIMARY KEY (`connection_group_id`),
UNIQUE KEY `connection_group_name` (`connection_group_name`),
CONSTRAINT `guacamole_connection_group_ibfk_1`
FOREIGN KEY (`parent_group_id`)
REFERENCES `guacamole_connection_group` (`connection_group_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --
-- Table of connections. Each connection has a name, protocol, and -- Table of connections. Each connection has a name, protocol, and
-- associated set of parameters. -- associated set of parameters.
-- A connection may belong to a connection group.
-- --
CREATE TABLE `guacamole_connection` ( CREATE TABLE `guacamole_connection` (
`connection_id` int(11) NOT NULL AUTO_INCREMENT, `connection_id` int(11) NOT NULL AUTO_INCREMENT,
`connection_name` varchar(128) NOT NULL, `connection_name` varchar(128) NOT NULL,
`protocol` varchar(32) NOT NULL, `connection_group_id` int(11),
`protocol` varchar(32) NOT NULL,
PRIMARY KEY (`connection_id`), PRIMARY KEY (`connection_id`),
UNIQUE KEY `connection_name` (`connection_name`) UNIQUE KEY `connection_name` (`connection_name`),
CONSTRAINT `guacamole_connection_ibfk_1`
FOREIGN KEY (`connection_group_id`)
REFERENCES `guacamole_connection_group` (`connection_group_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -77,6 +102,32 @@ CREATE TABLE `guacamole_connection_permission` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Table of connection group permissions. Each group permission grants a user
-- specific access to a connection group.
--
CREATE TABLE `guacamole_connection_group_permission` (
`user_id` int(11) NOT NULL,
`connection_group_id` int(11) NOT NULL,
`permission` enum('READ',
'UPDATE',
'DELETE',
'ADMINISTER') NOT NULL,
PRIMARY KEY (`user_id`,`connection_group_id`,`permission`),
CONSTRAINT `guacamole_connection_group_permission_ibfk_1`
FOREIGN KEY (`connection_group_id`)
REFERENCES `guacamole_connection_group` (`connection_group_id`) ON DELETE CASCADE,
CONSTRAINT `guacamole_connection_group_permission_ibfk_2`
FOREIGN KEY (`user_id`)
REFERENCES `guacamole_user` (`user_id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --
-- Table of system permissions. Each system permission grants a user a -- Table of system permissions. Each system permission grants a user a
-- system-level privilege of some kind. -- system-level privilege of some kind.
@@ -86,6 +137,7 @@ CREATE TABLE `guacamole_system_permission` (
`user_id` int(11) NOT NULL, `user_id` int(11) NOT NULL,
`permission` enum('CREATE_CONNECTION', `permission` enum('CREATE_CONNECTION',
'CREATE_GROUP',
'CREATE_USER', 'CREATE_USER',
'ADMINISTER') NOT NULL, 'ADMINISTER') NOT NULL,

View File

@@ -0,0 +1,62 @@
--
-- Table of connection groups. Each connection group has a name.
--
CREATE TABLE `guacamole_connection_group` (
`connection_group_id` int(11) NOT NULL AUTO_INCREMENT,
`parent_group_id` int(11),
`connection_group_name` varchar(128) NOT NULL,
PRIMARY KEY (`connection_group_id`),
UNIQUE KEY `connection_group_name` (`connection_group_name`),
CONSTRAINT `guacamole_connection_group_ibfk_1`
FOREIGN KEY (`parent_group_id`)
REFERENCES `guacamole_connection_group` (`connection_group_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Changes to connection table to support grouping.
--
ALTER TABLE `guacamole_connection` ADD COLUMN `connection_group_id` int(11) AFTER `connection_name`;
ALTER TABLE `guacamole_connection` ADD CONSTRAINT `guacamole_connection_ibfk_1`
FOREIGN KEY (`connection_group_id`)
REFERENCES `guacamole_connection_group` (`connection_group_id`);
--
-- Table of connection group permissions. Each group permission grants a user
-- specific access to a connection group.
--
CREATE TABLE `guacamole_connection_group_permission` (
`user_id` int(11) NOT NULL,
`connection_group_id` int(11) NOT NULL,
`permission` enum('READ',
'UPDATE',
'DELETE',
'ADMINISTER') NOT NULL,
PRIMARY KEY (`user_id`,`connection_group_id`,`permission`),
CONSTRAINT `guacamole_connection_group_permission_ibfk_1`
FOREIGN KEY (`connection_group_id`)
REFERENCES `guacamole_connection_group` (`connection_group_id`) ON DELETE CASCADE,
CONSTRAINT `guacamole_connection_group_permission_ibfk_2`
FOREIGN KEY (`user_id`)
REFERENCES `guacamole_user` (`user_id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `guacamole_system_permission` MODIFY `permission`
enum('CREATE_CONNECTION',
'CREATE_GROUP',
'CREATE_USER',
'ADMINISTER') NOT NULL;

View File

@@ -6,6 +6,7 @@ insert into guacamole_user values(1, 'guacadmin',
-- Grant this user create permissions -- Grant this user create permissions
insert into guacamole_system_permission values(1, 'CREATE_CONNECTION'); insert into guacamole_system_permission values(1, 'CREATE_CONNECTION');
insert into guacamole_system_permission values(1, 'CREATE_GROUP');
insert into guacamole_system_permission values(1, 'CREATE_USER'); insert into guacamole_system_permission values(1, 'CREATE_USER');
insert into guacamole_system_permission values(1, 'ADMINISTER'); insert into guacamole_system_permission values(1, 'ADMINISTER');