talira

db-cutover

Verified

Agent-friendly CLI and runbook for PostgreSQL blue/green upgrades using logical replication and PgBouncer

open sourceMITself-hostablefree

db-cutover upgrades a PostgreSQL database on RDS by copying it to a new instance at the target version, keeping the copy current with logical replication, and switching application traffic through PgBouncer in Kubernetes. The application keeps using the old database during the copy; at the switch, PgBouncer holds new queries while in-flight transactions finish, then sends the queued work to the new instance. It's a Python CLI with a step-by-step procedure and design notes, meant for a human operator working with a coding agent: each command has a narrow purpose, and every command that changes database, infrastructure or PgBouncer state needs --execute. It also does preflight checks, schema copy, sequence sync, verification, synthetic write probes, rehearsals and Terraform helpers for the new instance.

Problems it solves

  • upgrade our RDS Postgres major version without taking the app down
  • RDS blue/green deployments don't fit our setup and I want control over the switchover
  • move production traffic to a new Postgres instance with no failed requests
  • pause PgBouncer while in-flight transactions finish, then point it at the new database
  • keep a copy of a live Postgres database in sync with logical replication until we're ready to switch
  • sequences are behind on the replica after logical replication and inserts fail with duplicate keys
  • I want a coding agent to help run a database migration, but every destructive step needs my explicit approval
  • rehearse a database cutover before doing it for real
  • verify the new Postgres instance has the same data as the old one before switching
  • write synthetic probe rows during a migration to prove no writes were lost
  • generate the Terraform for a new RDS instance at the target Postgres version
  • zero-downtime Postgres 16 to 17 upgrade with PgBouncer in Kubernetes

Features

  • preflight checks
  • prepare BLUE for logical replication
  • Terraform for GREEN and for promoting it
  • schema copy, replication start and sync wait
  • data verification with an optional replicated marker write
  • sequence sync
  • PgBouncer pause, reload and resume cutover with rehearsal mode
  • health and replication watch, synthetic write probes
  • dry run by default; --execute for every change
  • 1Password secret references

Capabilities

Has a command line toolplan not known