-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1391 from cityofaustin/md-18450-fdu-fields
Create generated columns to show fund name and FDU format in project funding table
- Loading branch information
Showing
3 changed files
with
37 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
moped-database/migrations/1723496266685_add_fdu_columns/down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
11
moped-database/migrations/1723496266685_add_fdu_columns/up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |