diff --git a/moped-database/metadata/tables.yaml b/moped-database/metadata/tables.yaml index e4341e898c..b65de28695 100644 --- a/moped-database/metadata/tables.yaml +++ b/moped-database/metadata/tables.yaml @@ -5493,6 +5493,9 @@ - workgroup_name filter: {} allow_aggregations: true +- table: + name: project_funding_view + schema: public - table: name: project_geography schema: public diff --git a/moped-database/migrations/1736291471358_add_proj_fund_view/down.sql b/moped-database/migrations/1736291471358_add_proj_fund_view/down.sql new file mode 100644 index 0000000000..6a7212b820 --- /dev/null +++ b/moped-database/migrations/1736291471358_add_proj_fund_view/down.sql @@ -0,0 +1 @@ +DROP VIEW project_funding_view; diff --git a/moped-database/migrations/1736291471358_add_proj_fund_view/up.sql b/moped-database/migrations/1736291471358_add_proj_fund_view/up.sql new file mode 100644 index 0000000000..859ef5f717 --- /dev/null +++ b/moped-database/migrations/1736291471358_add_proj_fund_view/up.sql @@ -0,0 +1,22 @@ +CREATE OR REPLACE VIEW project_funding_view AS +SELECT + mp.project_id, + mpf.proj_funding_id, + mpf.funding_amount, + mpf.funding_description, + mpf.fund_dept_unit, + mpf.created_at, + mpf.updated_at, + mfs.funding_source_name, + mfp.funding_program_name, + mfst.funding_status_name +FROM + moped_project AS mp +LEFT JOIN moped_proj_funding AS mpf ON mp.project_id = mpf.project_id +LEFT JOIN moped_fund_sources AS mfs ON mpf.funding_source_id = mfs.funding_source_id +LEFT JOIN moped_fund_programs AS mfp ON mpf.funding_program_id = mfp.funding_program_id +LEFT JOIN moped_fund_status AS mfst ON mpf.funding_status_id = mfst.funding_status_id +WHERE + TRUE + AND mp.is_deleted = FALSE + AND mpf.is_deleted = FALSE; diff --git a/moped-database/views/project_funding_view.sql b/moped-database/views/project_funding_view.sql new file mode 100644 index 0000000000..ffe0ef676c --- /dev/null +++ b/moped-database/views/project_funding_view.sql @@ -0,0 +1,19 @@ +-- Most recent migration: moped-database/migrations/1736291471358_add_proj_fund_view/up.sql + +CREATE OR REPLACE VIEW project_funding_view AS SELECT + mp.project_id, + mpf.proj_funding_id, + mpf.funding_amount, + mpf.funding_description, + mpf.fund_dept_unit, + mpf.created_at, + mpf.updated_at, + mfs.funding_source_name, + mfp.funding_program_name, + mfst.funding_status_name +FROM moped_project mp +LEFT JOIN moped_proj_funding mpf ON mp.project_id = mpf.project_id +LEFT JOIN moped_fund_sources mfs ON mpf.funding_source_id = mfs.funding_source_id +LEFT JOIN moped_fund_programs mfp ON mpf.funding_program_id = mfp.funding_program_id +LEFT JOIN moped_fund_status mfst ON mpf.funding_status_id = mfst.funding_status_id +WHERE true AND mp.is_deleted = false AND mpf.is_deleted = false;