Skip to content

Commit

Permalink
feat: flag on cif_user table to allow or disallow session_sub update
Browse files Browse the repository at this point in the history
  • Loading branch information
pbastia authored and dleard committed Nov 29, 2022
1 parent 0faa455 commit d6c9e35
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
20 changes: 20 additions & 0 deletions schema/deploy/tables/cif_user_004_allow_sub_update_flag.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-- Deploy cif:tables/cif_user_004_allow_sub_update_flag to pg
-- requires: tables/cif_user_003_create_policies

begin;


alter table cif.cif_user
add column allow_sub_update boolean not null default false;

create trigger cif_user_session_sub_immutable_with_flag
before update of session_sub on cif.cif_user
for each row
execute function cif_private.cif_user_session_sub_immutable_with_flag_set();

-- Allowing all the existing users to update the sub once.
update cif.cif_user set allow_sub_update = true;



commit;
7 changes: 7 additions & 0 deletions schema/revert/tables/cif_user_004_allow_sub_update_flag.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- Revert cif:tables/cif_user_004_allow_sub_update_flag from pg

begin;

alter table cif.cif_user drop column allow_sub_update;

commit;
7 changes: 7 additions & 0 deletions schema/verify/tables/cif_user_004_allow_sub_update_flag.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- Verify cif:tables/cif_user_004_allow_sub_update_flag on pg

begin;

select allow_sub_update from cif.cif_user limit 0;

rollback;

0 comments on commit d6c9e35

Please sign in to comment.