Creates <schema>.streams and <schema>.streams_habitat_<sp> (one
per species) with IF NOT EXISTS. Idempotent — safe to call before
every per-WSG run, and safe under concurrent first-time provisioning
(multiple workers can race; only one CREATE wins).
Arguments
- conn
DBI connection.
- cfg
An
lnk_configobject withcfg$pipeline$schemaset.- species
Character vector of species codes (uppercased) to create
streams_habitat_<sp>tables for. Typically derived vialnk_pipeline_species()orunique(loaded$parameters_fresh$species_code).- force_recreate
Logical. When
TRUE, drop any existing target tables whose DDL doesn't match the expected shape — specifically, tables that have unexpectedGENERATED ALWAYScolumns. DefaultFALSEerrors loud instead so the operator can audit before the destructive recreate. Use when spinning a new host from a snapshot whose fwapg volume carries stalefresh.streamsDDL (e.g. cypher snapshots baked whenfrs_col_generate()had been run on the persist schema). See link#162 Phase 7 hardening.
Details
Per-WSG data accumulates into these tables via lnk_pipeline_persist()
after each run. Queryable cross-WSG for cartography, intrinsic
potential maps, and per-crossing upstream rollups.
Column shape mirrors bcfp's bcfishpass.streams +
bcfishpass.habitat_linear_<sp> for familiarity. Driven by the
cols_streams / cols_habitat vectors at the top of this file —
single source of truth shared with lnk_pipeline_persist().
Examples
if (FALSE) { # \dontrun{
conn <- lnk_db_conn()
cfg <- lnk_config("bcfishpass")
loaded <- lnk_load_overrides(cfg)
species <- unique(loaded$parameters_fresh$species_code)
# First-time setup or healthy state: idempotent CREATE IF NOT EXISTS.
lnk_persist_init(conn, cfg, species)
# If a snapshot-baked DB has stale GENERATED columns on fresh.streams:
lnk_persist_init(conn, cfg, species, force_recreate = TRUE)
} # }
