forked from avniproject/avni-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
avniproject#762|Question creation for Programs and Encounters with Ad…
…dress table automated
- Loading branch information
1 parent
55393b5
commit fdd1085
Showing
6 changed files
with
144 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
avni-server-api/src/main/resources/db/migration/V1_339_1__GroupPrivilegeConstraint.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
alter table group_privilege add column if not exists impl_version int not null default 1; | ||
|
||
update group_privilege | ||
set impl_version = 0 | ||
where is_voided = true; | ||
|
||
create or replace function check_group_privilege_uniqueness(groupPrivilegeId int, groupId int, privilegeId int, subjectTypeId int, programId int, programEncounterTypeId int, encounterTypeId int, checklistDetailId int, implVersion int) returns boolean | ||
language plpgsql | ||
as | ||
$$ | ||
declare | ||
begin | ||
if exists (select gp.* | ||
from public.group_privilege gp | ||
where gp.group_id = groupId | ||
and gp.privilege_id = privilegeId | ||
and (gp.subject_type_id = subjectTypeId or (gp.subject_type_id is null and subjectTypeId is null)) | ||
and (gp.program_id = programId or (gp.program_id is null and programId is null)) | ||
and (gp.program_encounter_type_id = programEncounterTypeId or (gp.program_encounter_type_id is null and programEncounterTypeId is null)) | ||
and (gp.encounter_type_id = encounterTypeId or (gp.encounter_type_id is null and encounterTypeId is null)) | ||
and (gp.checklist_detail_id = checklistDetailId or (gp.checklist_detail_id is null and checklistDetailId is null)) | ||
and gp.id <> groupPrivilegeId | ||
and gp.impl_version = 1 | ||
and implVersion = 1 | ||
) then | ||
raise 'Duplicate group privilege exists for: id: %, group_id: %, privilege_id: % subject_type_id: %, program_id: %, program_encounter_type_id: %, encounter_type_id: %, checklist_detail_id: %', groupPrivilegeId, groupId, privilegeId, subjectTypeId, programId, programEncounterTypeId, encounterTypeId, checklistDetailId; | ||
end if; | ||
|
||
return true; | ||
end | ||
$$; | ||
|
||
alter table group_privilege | ||
add constraint check_group_privilege_unique | ||
check (check_group_privilege_uniqueness(id, group_id, privilege_id, subject_type_id, program_id, program_encounter_type_id, encounter_type_id, checklist_detail_id, impl_version)); |
1 change: 1 addition & 0 deletions
1
avni-server-api/src/main/resources/db/migration/V1_339_2__OrganisationStatus.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
alter table organisation add column status varchar(255) not null default 'Live'; |
9 changes: 9 additions & 0 deletions
9
avni-server-api/src/main/resources/db/migration/V1_342__UpdateStandardCardTypeNames.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
UPDATE standard_report_card_type | ||
SET name = 'Recent registrations', description = 'Recent registrations', last_modified_date_time = current_timestamp | ||
WHERE name = 'Last 24 hours registrations'; | ||
UPDATE standard_report_card_type | ||
SET name = 'Recent enrolments', description = 'Recent enrolments', last_modified_date_time = current_timestamp | ||
WHERE name = 'Last 24 hours enrolments'; | ||
UPDATE standard_report_card_type | ||
SET name = 'Recent visits', description = 'Recent visits', last_modified_date_time = current_timestamp | ||
WHERE name = 'Last 24 hours visits'; |