Skip to content

Commit

Permalink
feat: project manager table migration
Browse files Browse the repository at this point in the history
  • Loading branch information
pbastia committed Dec 1, 2021
1 parent 1bfbc7e commit 52639d9
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
34 changes: 33 additions & 1 deletion schema/deploy/tables/project_manager.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,38 @@

begin;

-- XXX Add DDLs here.
create table cif.project_manager (
id integer primary key generated always as identity,
project_id integer not null references cif.project(id),
cif_user_id integer not null references cif.cif_user(id)
);

select cif_private.upsert_timestamp_columns('cif', 'project_manager');

do
$grant$
begin

-- Grant cif_internal permissions
perform cif_private.grant_permissions('select', 'project_manager', 'cif_internal');
perform cif_private.grant_permissions('insert', 'project_manager', 'cif_internal');
perform cif_private.grant_permissions('update', 'project_manager', 'cif_internal');

-- Grant cif_admin permissions
perform cif_private.grant_permissions('select', 'project_manager', 'cif_admin');
perform cif_private.grant_permissions('insert', 'project_manager', 'cif_admin');
perform cif_private.grant_permissions('update', 'project_manager', 'cif_admin');

-- Grant cif_external no permissions
-- Grant cif_guest no permissions

end
$grant$;

comment on table cif.project_manager is 'Join table to track assignment of cif users to projects, as project managers';
comment on column cif.project_manager.id is 'Unique ID for the project manager record';
comment on column cif.project_manager.project_id is 'Foreign key to the project';
comment on column cif.project_manager.cif_user_id is 'Foreign key to the cif user';


commit;
2 changes: 1 addition & 1 deletion schema/revert/tables/project_manager.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

begin;

-- XXX Add DDLs here.
drop table cif.project_manager;

commit;
13 changes: 12 additions & 1 deletion schema/verify/tables/project_manager.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

begin;

-- XXX Add verifications here.
select pg_catalog.has_table_privilege('cif.project_manager', 'select');

-- cif_internal Grants
select cif_private.verify_grant('select', 'project_manager', 'cif_internal');
select cif_private.verify_grant('insert', 'project_manager', 'cif_internal');
select cif_private.verify_grant('update', 'project_manager', 'cif_internal');

-- cif_admin Grants
select cif_private.verify_grant('select', 'project_manager', 'cif_admin');
select cif_private.verify_grant('insert', 'project_manager', 'cif_admin');
select cif_private.verify_grant('update', 'project_manager', 'cif_admin');


rollback;

0 comments on commit 52639d9

Please sign in to comment.