Repository navigation
feat(scripts): add bidirectional incremental DB sync (local <-> prod) - #25
Merged
Merged
Conversation
- scripts/sync_db.py: watermark-based incremental sync engine with INSERT ... ON CONFLICT upserts, latest-updated_at-wins conflicts, INSERT-only (deletes never propagated) - pre-sync pg_dump of both DBs; verified auto-restore on failure via pg_restore --clean --if-exists (fault-injection tested) - fetch from the older of the two watermarks so a fresh prod target gets a full scan instead of silently receiving nothing - alembic migration for the sync_state watermark table - scripts/sync-db.sh wrapper reads local creds from .env; PROD_URL is runtime-only and never stored - Makefile: sync-db / sync-db-dry / sync-db-status / sync-db-reset plus an isolated test harness on port 5433; replaces one-way sync-prod - CLAUDE.md: document usage Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- keep main's Makefile improvements (.SHELLFLAGS, db-status, shellcheck lint, safer migrations/clean) while replacing sync-prod/push-prod targets with the bidirectional sync-db targets - remove scripts/push-to-prod.sh and scripts/sync-prod.sh: both one-way flows are superseded by scripts/sync_db.py - update README and CLAUDE.md sync docs accordingly Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
dipto0321
temporarily deployed
to
feat/bidirectional-db-sync - spendrift-be PR #25
July 21, 2026 14:23 — with
Render
Destroyed
|
❌ Found 1 compliant commit and 1 non-compliant commits in bb3dd11...50b1c9a. Commit 50b1c9a by @dipto0321 is not conform to the conventional commit specification :
Co-Authored-By: Claude Fable 5 noreply@anthropic.com`
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the one-way
sync-prod.shwith a bidirectional, watermark-based incremental sync between local and production Postgres.scripts/sync_db.py— sync engine: per-tableINSERT ... ON CONFLICT DO UPDATEupserts, latest-updated_at-wins conflict resolution, INSERT-only (deletes never propagated), idempotent watermark advance via newsync_statetablepg_dumps both DBs before any mutation and auto-restores both on failure (fault-injection tested)alembic/versions/87927e56a6f2— migration adding thesync_statewatermark table (applies to prod automatically on deploy via the Dockerfile'salembic upgrade head)scripts/sync-db.sh— wrapper loading local creds from.env;PROD_URLis passed at runtime and never storedsync-db,sync-db-dry,sync-db-status,sync-db-reset, plus an isolated test harness (sync-db-test-*) on port 5433Test plan
sync_state)--keep-dump🤖 Generated with Claude Code