Skip to content

Commit

Permalink
Merge pull request #1391 from cityofaustin/md-18450-fdu-fields
Browse files Browse the repository at this point in the history
Create generated columns to show fund name and FDU format in project funding table
  • Loading branch information
mddilley authored Aug 14, 2024
2 parents b59265c + 632fb7a commit 20ce0aa
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 18 deletions.
42 changes: 24 additions & 18 deletions moped-database/metadata/tables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2556,56 +2556,62 @@
- role: moped-admin
permission:
columns:
- created_at
- created_by_user_id
- dept_unit
- fund
- fund_dept_unit
- fund_name
- funding_amount
- funding_description
- funding_program_id
- funding_source_id
- funding_status_id
- project_id
- proj_funding_id
- dept_unit
- fund
- funding_description
- created_at
- is_deleted
- proj_funding_id
- project_id
- updated_at
- updated_by_user_id
filter: {}
allow_aggregations: true
- role: moped-editor
permission:
columns:
- created_at
- created_by_user_id
- dept_unit
- fund
- fund_dept_unit
- fund_name
- funding_amount
- funding_description
- funding_program_id
- funding_source_id
- funding_status_id
- project_id
- proj_funding_id
- dept_unit
- fund
- funding_description
- created_at
- is_deleted
- proj_funding_id
- project_id
- updated_at
- updated_by_user_id
filter: {}
allow_aggregations: true
- role: moped-viewer
permission:
columns:
- created_at
- created_by_user_id
- dept_unit
- fund
- fund_dept_unit
- fund_name
- funding_amount
- funding_description
- funding_program_id
- funding_source_id
- funding_status_id
- project_id
- proj_funding_id
- dept_unit
- fund
- funding_description
- created_at
- is_deleted
- proj_funding_id
- project_id
- updated_at
- updated_by_user_id
filter: {}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Drop generated columns generated columns for fund_dept_unit and fund_name
ALTER TABLE moped_proj_funding DROP COLUMN IF EXISTS fund_dept_unit, DROP COLUMN IF EXISTS fund_name;
11 changes: 11 additions & 0 deletions moped-database/migrations/1723496266685_add_fdu_columns/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- Add generated columns for fund_dept_unit and fund_name
ALTER TABLE moped_proj_funding
ADD COLUMN fund_dept_unit text GENERATED ALWAYS AS (CASE WHEN (fund IS null OR dept_unit IS null) THEN null ELSE
coalesce(fund ->> 'fund_id', ' ') || ' ' || coalesce(dept_unit ->> 'dept', ' ') || ' ' || coalesce(dept_unit ->> 'unit', ' ')
END) STORED,
ADD COLUMN fund_name text GENERATED ALWAYS AS (
CASE WHEN fund IS null THEN null ELSE coalesce(fund ->> 'fund_name', ' ') END
) STORED;

COMMENT ON COLUMN moped_proj_funding.fund_dept_unit IS 'Fund, department, and unit numbers concatenated; null if fund or unit is not populated';
COMMENT ON COLUMN moped_proj_funding.fund_name IS 'Fund name; null if fund is not populated';

0 comments on commit 20ce0aa

Please sign in to comment.