Skip to content

Commit f8ea817

Browse files
committed
Merge branch 'main' of github.com:smnorris/bcfishpass
* 'main' of github.com:smnorris/bcfishpass: document cabd fix tables (#742)
2 parents 80fbfde + 72b5c6c commit f8ea817

File tree

5 files changed

+126
-2
lines changed

5 files changed

+126
-2
lines changed

data/README.md

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,69 @@
1-
# Data files
1+
# Data and fix tables
22

3-
User editable data inputs - mostly fix tables.
3+
User editable data inputs and fixes - mostly fix tables.
4+
5+
To make a fix to bcfishpass inputs via these tables:
6+
7+
- clone the repository
8+
- edit the file of interest, making the required fix/addition
9+
- create a pull request
410

511
## cabd_additions
612

13+
Insert falls or dams required for bcfishpass but not present in CABD. Includes placeholders for dams outside of BC
14+
15+
| Column | Type | Description |
16+
|--------|------|-------------|
17+
| `feature_type` | `text` | Feature type, either waterfalls or dams |
18+
| `name` | `text` | Name of waterfalls or dam |
19+
| `height` | `numeric` | Height (m) of waterfalls or dam |
20+
| `barrier_ind` | `boolean` | Barrier status of waterfalls or dam (true/false) |
21+
| `blue_line_key` | `integer` | FWA blue_line_key (flow line) on which the feature lies |
22+
| `downstream_route_measure` | `integer` | The distance, in meters, along the blue_line_key from the mouth of the stream/blue_line_key to the feature. |
23+
| `reviewer_name` | `text` | Initials of user submitting the review, eg SN |
24+
| `review_date` | `date` | Date of review, in form YYYY-MM-DD eg 2025-01-07 |
25+
| `source` | `text` | Description or link to the source(s) documenting the feature |
26+
| `notes` | `text` | Reviewer notes on rationale for addition of the feature and/or how the source were interpreted |
27+
728
## cabd_blkey_xref
829

30+
Cross reference CABD features to FWA flow lines (blue_line_key), used when CABD feature location is closest to an inapproprate flow line
31+
32+
| Column | Type | Description |
33+
|--------|------|-------------|
34+
| `cabd_id` | `text` | CABD unique identifier |
35+
| `blue_line_key` | `integer` | FWA blue_line_key (flow line) to which the CABD feature should be linked |
36+
| `reviewer_name` | `text` | Initials of user submitting the review, eg SN |
37+
| `review_date` | `date` | Date of review, in form YYYY-MM-DD eg 2025-01-07 |
38+
| `notes` | `text` | Reviewer notes on rationale for fix and/or how the source(s) were interpreted |
39+
940
## cabd_exclusions
1041

42+
Exclude CABD records (waterfalls and dams) from bcfishpass usage
43+
44+
| Column | Type | Description |
45+
|--------|------|-------------|
46+
| `cabd_id` | `text` | CABD unique identifier |
47+
| `feature_type` | `text` | Feature type, either waterfalls or dams |
48+
| `reviewer_name` | `text` | Initials of user submitting the review, eg SN |
49+
| `review_date` | `date` | Date of review, in form YYYY-MM-DD eg 2025-01-07 |
50+
| `source` | `text` | Description or link to the source(s) indicating why the feature should be excluded |
51+
| `notes` | `text` | Reviewer notes on rationale for exclusion and/or how the source were interpreted |
52+
1153
## cabd_passability_status_updates
1254

55+
Update the passability_status_code (within bcfishpass) of existing CABD features (dams or waterfalls)
56+
57+
| Column | Type | Description |
58+
|--------|------|-------------|
59+
| `cabd_id` | `text` | CABD unique identifier |
60+
| `passability_status_code` | `integer` | Code referencing the degree to which the feature acts as a barrier to fish in the upstream direction. (1=Barrier, 2=Partial barrier, 3=Passable, 4=Unknown, 5=NA-No Structure, 6=NA-Decommissioned/Removed) |
61+
| `reviewer_name` | `text` | Initials of user submitting the review, eg SN |
62+
| `review_date` | `date` | Date of review, in form YYYY-MM-DD eg 2025-01-07 |
63+
| `source` | `text` | Description or link to the source(s) documenting the passability status of the feature |
64+
| `notes` | `text` | Reviewer notes on rationale for fix and/or how the source(s) were interpreted |
65+
66+
1367
## dfo_known_sockeye_lakes.csv
1468

1569
`waterbody_poly_id` of FWA lakes known to potentially support Sockeye

data/document.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
# document the various data and fix tables
4+
# usage: ./document.sh > README.md
5+
echo "# Data and fix table reference"
6+
echo -en '\n'
7+
8+
# value added tables
9+
for table in cabd_additions \
10+
cabd_blkey_xref \
11+
cabd_exclusions \
12+
cabd_passability_status_updates \
13+
14+
do
15+
echo "## $table"
16+
echo -en '\n'
17+
psql $DATABASE_URL -AtX -P border=0,footer=no -c "\dt+ bcfishpass.$table" | awk -F"|" '{print $8}'
18+
echo -en '\n'
19+
echo "| Column | Type | Description |"
20+
echo "|--------|------|-------------|"
21+
psql $DATABASE_URL -AtX -P border=0,footer=no -c "\d+ bcfishpass.$table" | awk -F"|" '{ print "| `"$1"` | `"$2"` | "$9" |"}'
22+
echo -en '\n'
23+
done

db/v0.7.7/README.md

Whitespace-only changes.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
BEGIN;
2+
3+
comment on table bcfishpass.cabd_exclusions IS 'Exclude CABD records (waterfalls and dams) from bcfishpass usage';
4+
comment on column bcfishpass.cabd_exclusions.cabd_id IS 'CABD unique identifier';
5+
comment on column bcfishpass.cabd_exclusions.feature_type IS 'Feature type, either waterfalls or dams';
6+
comment on column bcfishpass.cabd_exclusions.reviewer_name IS 'Initials of user submitting the review, eg SN';
7+
comment on column bcfishpass.cabd_exclusions.review_date IS 'Date of review, in form YYYY-MM-DD eg 2025-01-07';
8+
comment on column bcfishpass.cabd_exclusions.source IS 'Description or link to the source(s) indicating why the feature should be excluded';
9+
comment on column bcfishpass.cabd_exclusions.notes IS 'Reviewer notes on rationale for exclusion and/or how the source were interpreted';
10+
11+
comment on table bcfishpass.cabd_additions IS 'Insert falls or dams required for bcfishpass but not present in CABD. Includes placeholders for dams outside of BC';
12+
comment on column bcfishpass.cabd_additions.feature_type IS 'Feature type, either waterfalls or dams';
13+
comment on column bcfishpass.cabd_additions.name IS 'Name of waterfalls or dam';
14+
comment on column bcfishpass.cabd_additions.height IS 'Height (m) of waterfalls or dam';
15+
comment on column bcfishpass.cabd_additions.barrier_ind IS 'Barrier status of waterfalls or dam (true/false)';
16+
comment on column bcfishpass.cabd_additions.blue_line_key IS 'FWA blue_line_key (flow line) on which the feature lies';
17+
comment on column bcfishpass.cabd_additions.downstream_route_measure IS 'The distance, in meters, along the blue_line_key from the mouth of the stream/blue_line_key to the feature.';
18+
comment on column bcfishpass.cabd_additions.reviewer_name IS 'Initials of user submitting the review, eg SN';
19+
comment on column bcfishpass.cabd_additions.review_date IS 'Date of review, in form YYYY-MM-DD eg 2025-01-07';
20+
comment on column bcfishpass.cabd_additions.source IS 'Description or link to the source(s) documenting the feature';
21+
comment on column bcfishpass.cabd_additions.notes IS 'Reviewer notes on rationale for addition of the feature and/or how the source were interpreted';
22+
23+
comment on table bcfishpass.cabd_passability_status_updates IS 'Update the passability_status_code (within bcfishpass) of existing CABD features (dams or waterfalls)';
24+
comment on column bcfishpass.cabd_passability_status_updates.cabd_id IS 'CABD unique identifier';
25+
comment on column bcfishpass.cabd_passability_status_updates.passability_status_code IS 'Code referencing the degree to which the feature acts as a barrier to fish in the upstream direction. (1=Barrier, 2=Partial barrier, 3=Passable, 4=Unknown, 5=NA-No Structure, 6=NA-Decommissioned/Removed)';
26+
comment on column bcfishpass.cabd_passability_status_updates.reviewer_name IS 'Initials of user submitting the review, eg SN';
27+
comment on column bcfishpass.cabd_passability_status_updates.review_date IS 'Date of review, in form YYYY-MM-DD eg 2025-01-07';
28+
comment on column bcfishpass.cabd_passability_status_updates.source IS 'Description or link to the source(s) documenting the passability status of the feature';
29+
comment on column bcfishpass.cabd_passability_status_updates.notes IS 'Reviewer notes on rationale for fix and/or how the source(s) were interpreted';
30+
31+
comment on table bcfishpass.cabd_blkey_xref IS 'Cross reference CABD features to FWA flow lines (blue_line_key), used when CABD feature location is closest to an inapproprate flow line';
32+
comment on column bcfishpass.cabd_blkey_xref.cabd_id IS 'CABD unique identifier';
33+
comment on column bcfishpass.cabd_blkey_xref.blue_line_key IS 'FWA blue_line_key (flow line) to which the CABD feature should be linked';
34+
comment on column bcfishpass.cabd_blkey_xref.reviewer_name IS 'Initials of user submitting the review, eg SN';
35+
comment on column bcfishpass.cabd_blkey_xref.review_date IS 'Date of review, in form YYYY-MM-DD eg 2025-01-07';
36+
comment on column bcfishpass.cabd_blkey_xref.notes IS 'Reviewer notes on rationale for fix and/or how the source(s) were interpreted';
37+
38+
COMMIT;

db/v0.7.8/migrate.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
set -euxo pipefail
3+
4+
PSQL="psql $DATABASE_URL -v ON_ERROR_STOP=1"
5+
6+
# document the cabd fix tables
7+
$PSQL -f cabd_fix_table_comments.sql
8+
9+
$PSQL -c "update bcfishpass.db_version set tag = '${PWD##*/}'"

0 commit comments

Comments
 (0)