25 lines
986 B
Shell
25 lines
986 B
Shell
|
|
reset_lane_durable_store() {
|
||
|
|
local lane="$1"
|
||
|
|
local database="nuthatch_lane_$lane"
|
||
|
|
kube --namespace "$FIXTURE_NAMESPACE" exec deployment/postgres -- \
|
||
|
|
env PGPASSWORD=synthetic-postgres psql \
|
||
|
|
--username nuthatch \
|
||
|
|
--dbname postgres \
|
||
|
|
--set ON_ERROR_STOP=1 \
|
||
|
|
--command "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = '$database'" \
|
||
|
|
--command "DROP DATABASE IF EXISTS $database" \
|
||
|
|
--command "CREATE DATABASE $database" >&2 || return
|
||
|
|
printf '%s\n' "$database"
|
||
|
|
}
|
||
|
|
|
||
|
|
cleanup_lane_durable_store() {
|
||
|
|
local lane="$1"
|
||
|
|
local database="nuthatch_lane_$lane"
|
||
|
|
kube --namespace "$FIXTURE_NAMESPACE" exec deployment/postgres -- \
|
||
|
|
env PGPASSWORD=synthetic-postgres psql \
|
||
|
|
--username nuthatch \
|
||
|
|
--dbname postgres \
|
||
|
|
--set ON_ERROR_STOP=1 \
|
||
|
|
--command "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = '$database'" \
|
||
|
|
--command "DROP DATABASE IF EXISTS $database" >/dev/null
|
||
|
|
}
|