Skip to content

Commit

Permalink
feat: adding funding_parameters table
Browse files Browse the repository at this point in the history
  • Loading branch information
gurjmatharu authored and Sepehr-Sobhani committed Jul 8, 2022
1 parent 136620e commit ba5f47c
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
44 changes: 44 additions & 0 deletions schema/deploy/tables/funding_parameters.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
-- Deploy cif:tables/funding_parameters to pg

begin;

create table cif.funding_parameters(
id integer primary key generated always as identity,
project_id integer references cif.project(id) not null,
total_project_value numeric(10,2),
max_funding_amount numeric(10,2),
provence_share_percentage decimal(2,2),
holdback_percentage decimal(2,2),
anticipated_funding_amount numeric(10,2)
);

do
$grant$
begin

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

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

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

end
$grant$;

comment on table cif.funding_parameters is 'Table containing budget related data';
comment on column cif.funding_parameters.id is 'Unique ID for the budget data';
comment on column cif.funding_parameters.project_id is 'The related project for this data';
comment on column cif.funding_parameters.total_project_value is 'Total project value';
comment on column cif.funding_parameters.max_funding_amount is 'Maximum funding amount for this project';
comment on column cif.funding_parameters.provence_share_percentage is 'Provences share percentage';
comment on column cif.funding_parameters.holdback_percentage is 'Provence holds back this percentage of funding';
comment on column cif.funding_parameters.anticipated_funding_amount is 'The anticipated funding amount';

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


begin;

drop table cif.funding_parameters;

commit;
1 change: 1 addition & 0 deletions schema/sqitch.plan
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,4 @@ tables/emission_intensity_report [tables/reporting_requirement] 2022-06-22T20:29
tables/milestone_report [tables/reporting_requirement] 2022-06-22T21:01:22Z Dylan Leard <[email protected]> # Table containing data for milestone reports
mutations/add_milestone_to_revision [tables/reporting_requirement tables/form_change] 2022-06-23T23:26:45Z Dylan Leard <[email protected]> # A custom mutation chain to create form_change records for multiple tables when creating a milestone
mutations/discard_milestone_form_change [tables/form_change tables/project_revision] 2022-06-24T16:25:29Z Dylan Leard <[email protected]> # Custom mutation to discard a set of form_change records relating to a milestone_report
tables/funding_parameters 2022-06-23T17:34:25Z Gurjeet Matharu <[email protected]> # funding paramater table
17 changes: 17 additions & 0 deletions schema/verify/tables/funding_parameters.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
-- Verify cif:tables/funding_parameters on pg

begin;

select pg_catalog.has_table_privilege('cif.operator', 'select');

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

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

rollback;

0 comments on commit ba5f47c

Please sign in to comment.