Skip to content

Auto-fetch LSN in stop-cdc.sh#48

Open
DmitriiAn wants to merge 1 commit intomainfrom
feat/stop-cdc-auto-lsn
Open

Auto-fetch LSN in stop-cdc.sh#48
DmitriiAn wants to merge 1 commit intomainfrom
feat/stop-cdc-auto-lsn

Conversation

@DmitriiAn
Copy link
Copy Markdown
Contributor

stop-cdc.sh no longer takes an LSN argument. It queries
pg_current_wal_lsn() from the source, displays it, and asks
for confirmation [y/N] before writing to the sentinel — reducing
manual steps at cutover and adding a safety gate.

README and AGENTS.md updated to reflect the new usage

Unit tests for stop-cdc.sh

── environment validation ───────────────────────────────────────────────
  ok  missing env vars → exit 1
  ok  missing env vars → error names the variable

── psql LSN fetch ───────────────────────────────────────────────────────
  ok  psql failure → exit 1
  ok  psql failure → meaningful error
  ok  psql empty output → exit 1
  ok  psql empty output → meaningful error
  ok  fetched LSN is displayed before confirmation

── confirmation prompt ──────────────────────────────────────────────────
  ok  user answers n → exit 0
  ok  user answers n → aborted message
  ok  user presses Enter (empty) → exit 0
  ok  user presses Enter → aborted message
  ok  user answers Y → not aborted

── migration directory discovery ────────────────────────────────────────
  ok  no migration dir → exit 1
  ok  no migration dir → clear error
  ok  migration dir without source.db → exit 1
  ok  no source.db → clear error

── happy path ───────────────────────────────────────────────────────────
  ok  happy path → exit 0
  ok  happy path → confirmed sentinel message
  ok  happy path → LSN echoed in output
  ok  happy path → sentinel stored in DB
  ok  explicit MIGRATION_DIR → exit 0
  ok  explicit MIGRATION_DIR → sentinel confirmed
  ok  abort → sentinel not modified

All 23 tests passed.

@DmitriiAn DmitriiAn requested a review from teknogeek0 April 27, 2026 13:14
@DmitriiAn
Copy link
Copy Markdown
Contributor Author

@teknogeek0 once you approve it, I'll update this page as well: https://planetscale.com/docs/postgres/imports/postgres-migrate-pgcopydb#8-cutover

Screenshot 2026-05-05 at 14 38 36

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant