Skip to content

Implement database migration dry-run and rollback validation tooling #623

Description

@Smartdevs17

Context

Database migrations are applied directly to production with no dry-run capability. Failed migrations require manual database intervention and cause downtime.

Current Limitation/Problem

No dry-run, rollback testing, or schema drift detection. A failed ALTER TABLE migration locks the table for minutes.

Expected Outcome

Migration tooling: dry-run on read replica, automated rollback testing (down+up in CI), zero-downtime migration patterns (expand-migrate-contract), and schema drift detection.

Acceptance Criteria

  • Dry-run: run migration against read replica, report warnings and row counts, no actual changes
  • Rollback testing: CI runs migrate:down then migrate:up, both must succeed for every migration
  • Zero-downtime helper: expand-migrate-contract pattern with automated phase transitions
  • Schema drift detection: compare actual DB schema with expected schema from migrations, alert on drift
  • Migration linting: detect common issues (missing down migration, destructive changes without approval flag)
  • Lock detection: warn if migration requires ACCESS EXCLUSIVE lock that blocks writes
  • Edge case: migration timeout (configurable, default 30s, with progress logging)

Technical Scope

  • scripts/db-dry-run.sh - dry-run script against read replica
  • scripts/db-rollback-test.sh - rollback CI test (down + up)
  • scripts/db-validate.sh - migration linter and schema drift checker
  • db/migrations/ - migration template with zero-downtime phases
  • .github/workflows/db-migration.yml - CI migration validation workflow
  • backend/shared/db/ - migration runner with advisory lock support

Metadata

Metadata

Assignees

Labels

200-points200 point issueStellar WaveIssues in the Stellar wave programdrips-waveIssues in the Drips Wave programhighHigh complexity issue

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions