Skip to content

Commit

Permalink
Merge pull request #1520 from cityofaustin/mike/20009_funding_view
Browse files Browse the repository at this point in the history
Create database view of project funding data
  • Loading branch information
mddilley authored Jan 16, 2025
2 parents 3365e3a + 7ece856 commit 9f4c267
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
3 changes: 3 additions & 0 deletions moped-database/metadata/tables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5493,6 +5493,9 @@
- workgroup_name
filter: {}
allow_aggregations: true
- table:
name: project_funding_view
schema: public
- table:
name: project_geography
schema: public
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP VIEW project_funding_view;
22 changes: 22 additions & 0 deletions moped-database/migrations/1736291471358_add_proj_fund_view/up.sql
Original file line number Diff line number Diff line change
@@ -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;
19 changes: 19 additions & 0 deletions moped-database/views/project_funding_view.sql
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 9f4c267

Please sign in to comment.