Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register
Show
Ignore:
Timestamp:
07/25/08 00:22:18 (6 months ago)
Author:
bwolfe
Message:

Sideporting from trunk to 1.3.x branch
Added mysqldiff entries for privilege changes
Fixed relationship editor widget - #938

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs/branches/1.3.x/metadata/model/update-to-latest-db.mysqldiff.sql

    r4947 r5034  
    994994         
    995995        set FOREIGN_KEY_CHECKS = 0; 
    996     insert into role_privilege (role, privilege) select distinct role, 'View Patient Programs' from role_privilege where privilege = 'Manage Patient Programs'; 
    997         insert into role_privilege (role, privilege) select distinct role, 'Edit Patient Programs' from role_privilege where privilege = 'Manage Patient Programs'; 
     996         
     997    insert into role_privilege (role, privilege) select distinct role, 'View Patient Programs' from role_privilege rp where privilege = 'Manage Patient Programs' and not exists (select * from role_privilege where role = rp.role and privilege = 'View Patient Programs'); 
     998        insert into role_privilege (role, privilege) select distinct role, 'Edit Patient Programs' from role_privilege rp where privilege = 'Manage Patient Programs' and not exists (select * from role_privilege where role = rp.role and privilege = 'Edit Patient Programs'); 
    998999        update role_privilege set privilege = 'Delete Patient Programs' where privilege = 'Manage Patient Programs'; 
    9991000         
     
    10421043call diff_procedure('1.3.0.13'); 
    10431044 
     1045#---------------------------------------- 
     1046# OpenMRS Datamodel version 1.3.0.14 
     1047# Ben Wolfe               July 24th, 2008 
     1048# Giving 1.3 modified privileges to roles 
     1049#---------------------------------------- 
     1050 
     1051#-- temporary procedure to check and add a privilege to the Authenticated role 
     1052DROP PROCEDURE IF EXISTS insert_authenticated_privilege; 
     1053delimiter // 
     1054CREATE PROCEDURE insert_authenticated_privilege (IN priv VARCHAR(50)) 
     1055 BEGIN 
     1056        IF NOT EXISTS (SELECT * FROM role_privilege where role = 'Authenticated' and privilege = priv) THEN 
     1057                insert into role_privilege (role, privilege) values ('Authenticated', priv); 
     1058        END IF; 
     1059 END; 
     1060// 
     1061delimiter ; 
     1062 
     1063DROP PROCEDURE IF EXISTS diff_procedure; 
     1064 
     1065delimiter // 
     1066 
     1067CREATE PROCEDURE diff_procedure (IN new_db_version VARCHAR(10)) 
     1068 BEGIN 
     1069    IF (SELECT REPLACE(property_value, '.', '0') < REPLACE(new_db_version, '.', '0') FROM global_property WHERE property = 'database_version') THEN 
     1070    SELECT CONCAT('Updating to ', new_db_version) AS 'Datamodel Update:' FROM dual; 
     1071         
     1072        set FOREIGN_KEY_CHECKS = 0; 
     1073         
     1074    insert into role_privilege (role, privilege) select distinct role, 'View Patient Programs' from role_privilege rp where privilege = 'Manage Patient Programs' and not exists (select * from role_privilege where role = rp.role and privilege = 'View Patient Programs'); 
     1075        insert into role_privilege (role, privilege) select distinct role, 'Edit Patient Programs' from role_privilege rp where privilege = 'Manage Patient Programs' and not exists (select * from role_privilege where role = rp.role and privilege = 'Edit Patient Programs'); 
     1076        update role_privilege set privilege = 'Delete Patient Programs' where privilege = 'Manage Patient Programs'; 
     1077         
     1078        #-- the 1.3.0.14 update didn't do this change correctly 
     1079        update role_privilege set privilege = 'Manage Concepts' where privilege = 'Edit Concepts'; 
     1080        update role_privilege set privilege = 'Manage Forms' where privilege = 'Edit Forms'; 
     1081         
     1082        #-- The concept proposal privilege changed slightly 
     1083        insert into role_privilege (role, privilege) select distinct role, 'Add Concept Proposals' from role_privilege rp where privilege = 'Add Concept Proposal' and not exists (select * from role_privilege where role = rp.role and privilege = 'Add Concept Proposals'); 
     1084        insert into role_privilege (role, privilege) select distinct role, 'Edit Concept Proposals' from role_privilege rp where privilege = 'Edit Concept Proposal' and not exists (select * from role_privilege where role = rp.role and privilege = 'Edit Concept Proposals'); 
     1085         
     1086        #-- These objects/methods now require an explicit privilege.  Previously they only required authentication 
     1087        call insert_authenticated_privilege('View Encounter Types'); 
     1088        call insert_authenticated_privilege('View Locations'); 
     1089        call insert_authenticated_privilege('View Mime Types'); 
     1090        call insert_authenticated_privilege('View Identifier Types'); 
     1091        call insert_authenticated_privilege('View Concept Classes'); 
     1092        call insert_authenticated_privilege('View Concept Datatypes'); 
     1093        call insert_authenticated_privilege('View Privileges'); 
     1094        call insert_authenticated_privilege('View Roles'); 
     1095        call insert_authenticated_privilege('View Field Types'); 
     1096        call insert_authenticated_privilege('View Order Types'); 
     1097        call insert_authenticated_privilege('View RelationshipTypes'); 
     1098        call insert_authenticated_privilege('View Global Properties'); 
     1099        call insert_authenticated_privilege('View Person Attribute Types'); 
     1100        call insert_authenticated_privilege('View Relationships'); 
     1101        call insert_authenticated_privilege('View Tribes'); 
     1102         
     1103        #-- If a role can View Patients...add the new View Patient Identifiers privilege to that role 
     1104        insert into role_privilege (role, privilege) select distinct role, 'View Patient Identifiers' from role_privilege rp where privilege = 'View Patients' and not exists (select * from role_privilege where role = rp.role and privilege = 'View Patient Identifiers');    
     1105         
     1106        #-- Convert Manage Encounter Types 
     1107        insert into role_privilege (role, privilege) select distinct role, 'Add Encounter Types' from role_privilege rp where privilege = 'Manage Encounter Types' and not exists (select * from role_privilege where role = rp.role and privilege = 'Add Encounter Types'); 
     1108        insert into role_privilege (role, privilege) select distinct role, 'Edit Encounter Types' from role_privilege rp where privilege = 'Manage Encounter Types' and not exists (select * from role_privilege where role = rp.role and privilege = 'Edit Encounter Types'); 
     1109        update role_privilege set privilege = 'Delete Encounter Types' where privilege = 'Manage Encounter Types'; 
     1110         
     1111        #-- Convert Manage Relationships privilege 
     1112        insert into role_privilege (role, privilege) select distinct role, 'Add Relationships' from role_privilege rp where privilege = 'Manage Relationships' and not exists (select * from role_privilege where role = rp.role and privilege = 'Add Relationships'); 
     1113        insert into role_privilege (role, privilege) select distinct role, 'Edit Relationships' from role_privilege rp where privilege = 'Manage Relationships' and not exists (select * from role_privilege where role = rp.role and privilege = 'Edit Relationships'); 
     1114        update role_privilege set privilege = 'Delete Relationships' where privilege = 'Manage Relationships'; 
     1115         
     1116        set FOREIGN_KEY_CHECKS = 1; 
     1117 
     1118    UPDATE `global_property` SET property_value=new_db_version WHERE property = 'database_version'; 
     1119     
     1120    END IF; 
     1121 END; 
     1122// 
     1123 
     1124delimiter ; 
     1125call diff_procedure('1.3.0.14'); 
     1126 
    10441127#----------------------------------- 
    10451128# Clean up - Keep this section at the very bottom of diff script