feat(replicas): auto-heal slave data drift and no-store public settings

Add sync-replica-data repair on deploy, a publisher-side replica watch
(60s + after tenant/settings writes), REFRESH PUBLICATION after migrate,
and Cache-Control no-store on program-settings and get_version.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-18 12:32:30 +03:30
co-authored by Cursor
parent 668bbcc1db
commit 16d562caa5
13 changed files with 456 additions and 11 deletions
+24
View File
@@ -181,6 +181,30 @@ echo "== publisher"
cd "$API_DIR"
npx prisma migrate deploy
refresh_subscriptions() {
local dsn="$1"
mapfile -t subs < <(
run_psql "$(libpq_dsn "$dsn")" -v ON_ERROR_STOP=1 -At -c \
"SELECT subname FROM pg_subscription ORDER BY subname"
)
if ((${#subs[@]} == 0)); then
echo " ! no subscription — skip REFRESH PUBLICATION"
return 0
fi
for sub in "${subs[@]}"; do
echo " ALTER SUBSCRIPTION $sub REFRESH PUBLICATION (copy_data)"
# New tables added to FOR ALL TABLES are NOT replicated until this runs.
run_psql "$(libpq_dsn "$dsn")" -v ON_ERROR_STOP=1 -q \
-c "ALTER SUBSCRIPTION \"${sub}\" REFRESH PUBLICATION WITH (copy_data = true)"
done
}
echo "== refresh subscriptions (pick up new tables)"
for dsn in "${REPLICAS[@]}"; do
echo "== $(label "$dsn")"
refresh_subscriptions "$dsn"
done
echo
echo "Replicas apply DDL first, so the publisher can stream the new columns right away."
echo "Verify with: bash deploy/sync-replica-schema.sh --check"