Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register
Show
Ignore:
Timestamp:
08/06/08 17:17:55 (5 months ago)
Author:
mseaton
Message:

synchronization_bidirectional_branch: merge from [4734] to [5181].

Files:

Legend:

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

    r4969 r5183  
    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         
     
    10151016call diff_procedure('1.3.0.12'); 
    10161017 
     1018#---------------------------------------- 
     1019# OpenMRS Datamodel version 1.3.0.13 
     1020# Ben Wolfe               July 3, 2008 
     1021# Changing person.dead and person_attribute_type.searchable to tinyint 
     1022#---------------------------------------- 
     1023 
     1024DROP PROCEDURE IF EXISTS diff_procedure; 
     1025 
     1026delimiter // 
     1027 
     1028CREATE PROCEDURE diff_procedure (IN new_db_version VARCHAR(10)) 
     1029 BEGIN 
     1030    IF (SELECT REPLACE(property_value, '.', '0') < REPLACE(new_db_version, '.', '0') FROM global_property WHERE property = 'database_version') THEN 
     1031    SELECT CONCAT('Updating to ', new_db_version) AS 'Datamodel Update:' FROM dual; 
     1032         
     1033        ALTER TABLE person CHANGE COLUMN dead dead tinyint(1) NOT NULL DEFAULT '0'; 
     1034        ALTER TABLE person_attribute_type CHANGE COLUMN searchable searchable tinyint(1) NOT NULL DEFAULT '0'; 
     1035 
     1036    UPDATE `global_property` SET property_value=new_db_version WHERE property = 'database_version'; 
     1037     
     1038    END IF; 
     1039 END; 
     1040// 
     1041 
     1042delimiter ; 
     1043call diff_procedure('1.3.0.13'); 
     1044 
     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        insert into role_privilege (role, privilege) select distinct role, 'Delete Patient Programs' from role_privilege rp where privilege = 'Manage Patient Programs' and not exists (select * from role_privilege where role = rp.role and privilege = 'Delete Patient Programs'); 
     1077        delete from role_privilege where privilege = 'Manage Patient Programs'; 
     1078         
     1079        #-- the 1.3.0.12 update didn't do this change correctly 
     1080        update role_privilege set privilege = 'Manage Concepts' where privilege = 'Edit Concepts'; 
     1081        update role_privilege set privilege = 'Manage Forms' where privilege = 'Edit Forms'; 
     1082         
     1083        #-- The concept proposal privilege changed slightly 
     1084        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'); 
     1085        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'); 
     1086         
     1087        #-- These objects/methods now require an explicit privilege.  Previously they only required authentication 
     1088        call insert_authenticated_privilege('View Encounter Types'); 
     1089        call insert_authenticated_privilege('View Locations'); 
     1090        call insert_authenticated_privilege('View Mime Types'); 
     1091        call insert_authenticated_privilege('View Identifier Types'); 
     1092        call insert_authenticated_privilege('View Concept Classes'); 
     1093        call insert_authenticated_privilege('View Concept Datatypes'); 
     1094        call insert_authenticated_privilege('View Privileges'); 
     1095        call insert_authenticated_privilege('View Roles'); 
     1096        call insert_authenticated_privilege('View Field Types'); 
     1097        call insert_authenticated_privilege('View Order Types'); 
     1098        call insert_authenticated_privilege('View Relationship Types'); 
     1099        call insert_authenticated_privilege('View Global Properties'); 
     1100        call insert_authenticated_privilege('View Person Attribute Types'); 
     1101        call insert_authenticated_privilege('View Relationships'); 
     1102        call insert_authenticated_privilege('View Tribes'); 
     1103         
     1104        #-- If a role can View Patients...add the new View Patient Identifiers privilege to that role 
     1105        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');    
     1106         
     1107        #-- Convert Manage Encounter Types 
     1108        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'); 
     1109        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'); 
     1110        insert into role_privilege (role, privilege) select distinct role, 'Delete Encounter Types' from role_privilege rp where privilege = 'Manage Encounter Types' and not exists (select * from role_privilege where role = rp.role and privilege = 'Delete Encounter Types'); 
     1111        delete from role_privilege where privilege = 'Manage Encounter Types'; 
     1112         
     1113        #-- Convert Manage Relationships privilege 
     1114        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'); 
     1115        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'); 
     1116        insert into role_privilege (role, privilege) select distinct role, 'Delete Relationships' from role_privilege rp where privilege = 'Manage Relationships' and not exists (select * from role_privilege where role = rp.role and privilege = 'Delete Relationships'); 
     1117        delete from role_privilege where privilege = 'Manage Relationships'; 
     1118         
     1119        set FOREIGN_KEY_CHECKS = 1; 
     1120 
     1121    UPDATE `global_property` SET property_value=new_db_version WHERE property = 'database_version'; 
     1122     
     1123    END IF; 
     1124 END; 
     1125// 
     1126 
     1127delimiter ; 
     1128call diff_procedure('1.3.0.14'); 
     1129 
     1130DROP PROCEDURE IF EXISTS insert_authenticated_privilege; 
     1131 
     1132#---------------------------------------- 
     1133# OpenMRS Datamodel version 1.3.0.15 
     1134# Ben Wolfe               Aug 1st, 2008 
     1135# Fixing 1.3.0.14 modified authenticated role 
     1136#---------------------------------------- 
     1137DROP PROCEDURE IF EXISTS diff_procedure; 
     1138 
     1139delimiter // 
     1140 
     1141CREATE PROCEDURE diff_procedure (IN new_db_version VARCHAR(10)) 
     1142 BEGIN 
     1143    IF (SELECT REPLACE(property_value, '.', '0') < REPLACE(new_db_version, '.', '0') FROM global_property WHERE property = 'database_version') THEN 
     1144    SELECT CONCAT('Updating to ', new_db_version) AS 'Datamodel Update:' FROM dual; 
     1145         
     1146        # Fix the incorrect privilege name from the privious update 
     1147        update role_privilege set privilege = 'View Relationship Types' where privilege = 'View RelationshipTypes'; 
     1148 
     1149    UPDATE `global_property` SET property_value=new_db_version WHERE property = 'database_version'; 
     1150     
     1151    END IF; 
     1152 END; 
     1153// 
     1154 
     1155delimiter ; 
     1156call diff_procedure('1.3.0.15'); 
     1157 
     1158#---------------------------------------- 
     1159# OpenMRS Datamodel version 1.4.0.01 
     1160# Mike Seaton          July 28, 2008 
     1161# Adding accession_number to orders 
     1162#---------------------------------------- 
     1163 
     1164DROP PROCEDURE IF EXISTS diff_procedure; 
     1165 
     1166delimiter // 
     1167 
     1168CREATE PROCEDURE diff_procedure (IN new_db_version VARCHAR(10)) 
     1169 BEGIN 
     1170    IF (SELECT REPLACE(property_value, '.', '0') < REPLACE(new_db_version, '.', '0') FROM global_property WHERE property = 'database_version') THEN 
     1171    SELECT CONCAT('Updating to ', new_db_version) AS 'Datamodel Update:' FROM dual; 
     1172         
     1173        ALTER TABLE `orders` ADD COLUMN `accession_number` varchar(255) default NULL; 
     1174 
     1175    UPDATE `global_property` SET property_value=new_db_version WHERE property = 'database_version'; 
     1176     
     1177    END IF; 
     1178 END; 
     1179// 
     1180 
     1181delimiter ; 
     1182call diff_procedure('1.4.0.01'); 
    10171183 
    10181184#-----------------------------------