-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
db.v0.5.3 includes join_tracking_table_crossings_vw.sql and migrate.sh
- Loading branch information
1 parent
1a045a6
commit 46ad123
Showing
3 changed files
with
34 additions
and
1 deletion.
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
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,8 @@ | ||
#!/bin/bash | ||
set -euxo pipefail | ||
|
||
echo "On systems supporting CWF WCRP reporting, add join_tracking_table_crossings_view.sql" | ||
echo "psql $DATABASE_URL -f sql/join_tracking_table_crossings_view.sql" | ||
|
||
# note version | ||
psql $DATABASE_URL -c "update bcfishpass.db_version set tag = '${PWD##*/}'" |
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,25 @@ | ||
|
||
-- This function joins the tracking table to bcfishpass.crossings_wcrp_vw on the barrier ID | ||
create or replace function wcrp_hors.join_tracking_table_crossings_wcrp_vw(p_wcrp text) | ||
returns void | ||
as | ||
$$ | ||
begin | ||
execute format('create or replace view wcrp_%I.combined_tracking_table_crossings_wcrp_vw_%I as | ||
select | ||
cv.*, | ||
tt.* | ||
from bcfishpass.crossings_wcrp_vw cv | ||
join wcrp_%I.combined_tracking_table_%I tt | ||
on tt.barrier_id = cv.aggregated_crossings_id', p_wcrp, p_wcrp, p_wcrp, p_wcrp); | ||
end | ||
$$ | ||
language plpgsql; | ||
|
||
-- loop through each WCRP and create a view for each one | ||
with data (wcrp) as ( | ||
select wcrp | ||
from bcfishpass.wcrp_watersheds | ||
) | ||
select wcrp_hors.join_tracking_table_crossings_wcrp_vw(wcrp) | ||
from data; |