Add cash management schema and immediate variance alerts

This commit is contained in:
Krikorios
2026-05-06 10:51:55 +03:00
parent 1a3de58de6
commit 1896cbdd11
106 changed files with 16800 additions and 4604 deletions
+20
View File
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
# Run all SQL migrations from /sql/migrations/ in lexical order.
# On plain Postgres (no pg_cron extension), wrap any bare
# `create extension if not exists pg_cron;` line so it doesn't abort.
set -euo pipefail
TMPDIR_M=/tmp/migrations
mkdir -p "$TMPDIR_M"
echo ">> applying app migrations from /sql/migrations"
for f in /sql/migrations/*.sql; do
base="$(basename "$f")"
# Replace the bare pg_cron extension creation with a soft variant.
sed -E "s|^create extension if not exists pg_cron;|do \$\$ begin create extension if not exists pg_cron; exception when others then raise notice 'pg_cron unavailable, skipping schedules'; end \$\$;|i" "$f" > "$TMPDIR_M/$base"
echo ">> $base"
psql -v ON_ERROR_STOP=1 \
--username "$POSTGRES_USER" \
--dbname "$POSTGRES_DB" \
-f "$TMPDIR_M/$base"
done
echo ">> migrations complete"