Skip to content

Commit

Permalink
full rebase
Browse files Browse the repository at this point in the history
major changes to the script

Major changes

Everything works

first of many

renamed

renamed
  • Loading branch information
taracampbell authored and ridz1208 committed Feb 23, 2018
1 parent efeb72a commit 1693592
Show file tree
Hide file tree
Showing 13 changed files with 1,876 additions and 432 deletions.
156 changes: 78 additions & 78 deletions SQL/0000-00-01-Permission.sql
Original file line number Diff line number Diff line change
@@ -1,45 +1,20 @@
SET FOREIGN_KEY_CHECKS=0;


DROP TABLE IF EXISTS `permissions`;


DROP TABLE IF EXISTS `permissions_category`;


DROP TABLE IF EXISTS `user_perm_rel`;
DROP TABLE IF EXISTS `permission_category`;
DROP TABLE IF EXISTS `permission_category_permissions_rel`;
DROP TABLE IF EXISTS `users_permission_category_rel`;

SET FOREIGN_KEY_CHECKS=1;
--
-- Table structure for table `permissions_category`
--


CREATE TABLE `permissions_category` (
`ID` int(10) NOT NULL AUTO_INCREMENT,
`Description` varchar(255) NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


INSERT INTO `permissions_category` VALUES
(1,'Roles'),
(2,'Permission');


CREATE TABLE `permissions` (
`permID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`code` varchar(255) NOT NULL DEFAULT '',
`description` varchar(255) NOT NULL DEFAULT '',
`categoryID` int(10) NOT NULL DEFAULT '2',
PRIMARY KEY (`permID`),
UNIQUE KEY `code` (`code`),
KEY `fk_permissions_1_idx` (`categoryID`),
CONSTRAINT `fk_permissions_1`
FOREIGN KEY (`categoryID`)
REFERENCES `permissions_category` (`ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION
UNIQUE KEY `code` (`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


Expand All @@ -62,55 +37,56 @@ CREATE TABLE `user_perm_rel` (


INSERT INTO `permissions` VALUES
(1,'superuser','There can be only one Highlander','1'),
(2,'user_accounts','User management','2'),
(3,'user_accounts_multisite','Across all sites create and edit users','2'),
(4,'context_help','Edit help documentation','2'),
(5,'bvl_feedback','Behavioural QC','1'),
(6,'imaging_browser_qc','Edit imaging browser QC status','2'),
(7,'mri_efax','Edit MRI Efax files','2'),
(8,'send_to_dcc','Send to DCC','2'),
(9,'unsend_to_dcc','Reverse Send from DCC','2'),
(10,'access_all_profiles','Across all sites access candidate profiles','2'),
(11,'data_entry','Data entry','1'),
(12,'examiner_view','Add and certify examiners','2'),
(13,'examiner_multisite','Across all sites add and certify examiners','2'),
(14,'training','View and complete training','2'),
(15,'timepoint_flag','Edit exclusion flags','2'),
(16,'timepoint_flag_evaluate','Evaluate overall exclusionary criteria for the timepoint','2'),
(17,'conflict_resolver','Resolving conflicts','2'),
(18,'data_dict_view','View Data Dictionary (Parameter type descriptions)','2'),
(19,'violated_scans_view_allsites','Violated Scans: View all-sites Violated Scans','2'),
(20,'violated_scans_edit','Violated Scans: Edit MRI protocol table','2'),
(21,'data_integrity_flag','Data Integrity Flag','2'),
(22,'config','Edit configuration settings','2'),
(23,'imaging_browser_view_site','View own-site Imaging Browser pages','2'),
(24,'imaging_browser_view_allsites', 'View all-sites Imaging Browser pages', '2'),
(25,'dicom_archive_view_allsites', 'Across all sites view Dicom Archive module and pages', '2'),
(26,'reliability_edit_all', 'Access and Edit all Reliability profiles', '2'),
(27,'reliability_swap_candidates', 'Swap Reliability candidates across all sites', '2'),
(28,'instrument_builder', 'Instrument Builder: Create and Edit instrument forms', '2'),
(29,'data_dict_edit','Edit Data Dictionary','2'),
(30,'data_team_helper','Data Team Helper','2'),
(31,'candidate_parameter_view','View Candidate Parameters','2'),
(32,'candidate_parameter_edit','Edit Candidate Parameters','2'),
(33,'genomic_browser_view_site','View Genomic Browser data from own site','2'),
(34,'genomic_browser_view_allsites','View Genomic Browser data across all sites','2'),
(35,'document_repository_view','View and upload files in Document Repository','2'),
(36,'document_repository_delete','Delete files in Document Repository','2'),
(37,'server_processes_manager','View and manage server processes','2'),
(38,'imaging_uploader','Imaging Uploader','2'),
(39,'acknowledgements_view','View Acknowledgements','2'),
(40,'acknowledgements_edit','Edit Acknowledgements','2'),
(41,'dataquery_view','View Data Query Tool','2'),
(42,'genomic_data_manager','Manage the genomic files','2'),
(43,'media_write','Media files: Uploading/Downloading/Editing','2'),
(44,'media_read','Media files: Browsing','2'),
(45,'issue_tracker_reporter', 'Can add a new issue, edit own issue, comment on all', 2),
(46,'issue_tracker_developer', 'Can re-assign issues, mark issues as closed, comment on all, edit issues.', 2),
(47,'imaging_browser_phantom_allsites', 'Can access only phantom data from all sites in Imaging Browser', 2),
(48,'imaging_browser_phantom_ownsite', 'Can access only phantom data from own site in Imaging Browser', 2);

(1,'superuser','There can be only one Highlander'),
(2,'user_accounts','User management'),
(3,'user_accounts_multisite','Across all sites create and edit users'),
(4,'context_help','Edit help documentation'),
(5,'bvl_feedback','Behavioural QC'),
(6,'imaging_browser_qc','Edit imaging browser QC status'),
(7,'mri_efax','Edit MRI Efax files'),
(8,'send_to_dcc','Send to DCC'),
(9,'unsend_to_dcc','Reverse Send from DCC'),
(10,'access_all_profiles','Across all sites access candidate profiles'),
(11,'data_entry','Data entry'),
(12,'examiner_view','Add and certify examiners'),
(13,'examiner_multisite','Across all sites add and certify examiners'),
(14,'training','View and complete training'),
(15,'timepoint_flag','Edit exclusion flags'),
(16,'timepoint_flag_evaluate','Evaluate overall exclusionary criteria for the timepoint'),
(17,'conflict_resolver','Resolving conflicts'),
(18,'data_dict_view','View Data Dictionary (Parameter type descriptions)'),
(19,'violated_scans_view_allsites','Violated Scans: View all-sites Violated Scans'),
(20,'violated_scans_edit','Violated Scans: Edit MRI protocol table'),
(21,'data_integrity_flag','Data Integrity Flag'),
(22,'config','Edit configuration settings'),
(23,'edit_final_radiological_review','Can edit final radiological reviews'),
(24,'view_final_radiological_review','Can see final radiological reviews'),
(25,'imaging_browser_view_site','View own-site Imaging Browser pages'),
(26,'imaging_browser_view_allsites', 'View all-sites Imaging Browser pages'),
(27,'dicom_archive_view_allsites', 'Across all sites view Dicom Archive module and pages'),
(28,'reliability_edit_all', 'Access and Edit all Reliability profiles'),
(29,'reliability_swap_candidates', 'Swap Reliability candidates across all sites'),
(30,'instrument_builder', 'Instrument Builder: Create and Edit instrument forms'),
(31,'data_dict_edit','Edit Data Dictionary'),
(32,'data_team_helper','Data Team Helper'),
(33,'candidate_parameter_view','View Candidate Parameters'),
(34,'candidate_parameter_edit','Edit Candidate Parameters'),
(35,'genomic_browser_view_site','View Genomic Browser data from own site'),
(36,'genomic_browser_view_allsites','View Genomic Browser data across all sites'),
(37,'document_repository_view','View and upload files in Document Repository'),
(38,'document_repository_delete','Delete files in Document Repository'),
(39,'server_processes_manager','View and manage server processes'),
(40,'imaging_uploader','Imaging Uploader'),
(41,'acknowledgements_view','View Acknowledgements'),
(42,'acknowledgements_edit','Edit Acknowledgements'),
(43,'dataquery_view','View Data Query Tool'),
(44,'genomic_data_manager','Manage the genomic files'),
(45,'media_write','Media files: Uploading/Downloading/Editing'),
(46,'media_read','Media files: Browsing'),
(47,'issue_tracker_reporter', 'Can add a new issue, edit own issue, comment on all'),
(48,'issue_tracker_developer', 'Can re-assign issues, mark issues as closed, comment on all, edit issues.'),
(49,'imaging_browser_phantom_allsites', 'Can access only phantom data from all sites in Imaging Browser'),
(50,'imaging_browser_phantom_ownsite', 'Can access only phantom data from own site in Imaging Browser');

INSERT INTO `user_perm_rel` (userID, permID)
SELECT u.ID, p.permID
Expand All @@ -131,3 +107,27 @@ CREATE TABLE `notification_modules_perm_rel` (
-- populate notification perm table
INSERT INTO notification_modules_perm_rel SELECT nm.id, p.permID FROM notification_modules nm JOIN permissions p WHERE nm.module_name='media' AND (p.code='media_write' OR p.code='media_read');
INSERT INTO notification_modules_perm_rel SELECT nm.id, p.permID FROM notification_modules nm JOIN permissions p WHERE nm.module_name='document_repository' AND (p.code='document_repository_view' OR p.code='document_repository_delete');

CREATE TABLE `permission_category` (
`PermissionCategoryID` INTEGER unsigned NOT NULL AUTO_INCREMENT,
`Category` varchar(255),
`Label` varchar(255),
PRIMARY KEY (`PermissionCategoryID`),
UNIQUE KEY `UK_Category` (`Category`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `permission_category_permissions_rel` (
`PermissionCategoryID` INTEGER unsigned NOT NULL,
`PermissionID` INTEGER unsigned NOT NULL,
PRIMARY KEY (`PermissionCategoryID`,`PermissionID`),
CONSTRAINT `FK_permission_category_permissions_rel_PermissionCategoryID` FOREIGN KEY (`PermissionCategoryID`) REFERENCES `permission_category` (`PermissionCategoryID`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `FK_permission_category_permissions_rel_PermissionID` FOREIGN KEY (`PermissionID`) REFERENCES `permissions` (`permID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `users_permission_category_rel` (
`UserID` INTEGER unsigned NOT NULL,
`PermissionCategoryID` INTEGER unsigned NOT NULL,
PRIMARY KEY (`UserID`,`PermissionCategoryID`),
CONSTRAINT `FK_users_permission_category_rel_userID` FOREIGN KEY (`userID`) REFERENCES `users` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `FK_users_permission_category_rel_PermissionCategoryID` FOREIGN KEY (`PermissionCategoryID`) REFERENCES `permission_category` (`PermissionCategoryID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
29 changes: 29 additions & 0 deletions SQL/Archive/2017-03-10-addUserAccountsRoles.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
ALTER TABLE `permissions` DROP FOREIGN KEY `fk_permissions_1`;
ALTER TABLE `permissions` DROP INDEX `fk_permissions_1_idx`;
ALTER TABLE `permissions` DROP COLUMN `categoryID`;

DROP TABLE `permissions_category`;

CREATE TABLE `permission_category` (
`PermissionCategoryID` INTEGER unsigned NOT NULL AUTO_INCREMENT,
`Category` varchar(255),
`Label` varchar(255),
PRIMARY KEY (`PermissionCategoryID`),
UNIQUE KEY `UK_Category` (`Category`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `permission_category_permissions_rel` (
`PermissionCategoryID` INTEGER unsigned NOT NULL,
`PermissionID` INTEGER unsigned NOT NULL,
PRIMARY KEY (`PermissionCategoryID`,`PermissionID`),
CONSTRAINT `FK_permission_category_permissions_rel_PermissionCategoryID` FOREIGN KEY (`PermissionCategoryID`) REFERENCES `permission_category` (`PermissionCategoryID`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `FK_permission_category_permissions_rel_PermissionID` FOREIGN KEY (`PermissionID`) REFERENCES `permissions` (`permID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `users_permission_category_rel` (
`UserID` INTEGER unsigned NOT NULL,
`PermissionCategoryID` INTEGER unsigned NOT NULL,
PRIMARY KEY (`UserID`,`PermissionCategoryID`),
CONSTRAINT `FK_users_permission_category_rel_userID` FOREIGN KEY (`userID`) REFERENCES `users` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `FK_users_permission_category_rel_PermissionCategoryID` FOREIGN KEY (`PermissionCategoryID`) REFERENCES `permission_category` (`PermissionCategoryID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Loading

0 comments on commit 1693592

Please sign in to comment.