Data & releases
GAHobby, Pro, ScaleRoll back your app and its managed PostgreSQL database together
Undo a broken release across both application code and managed PostgreSQL in one phased operation that preserves post-deploy writes in the original database.
Roll back code and database together, or restore data independently
Rolling back an application container without reversing its schema migration often leaves production broken. Gregale coordinates code rollback and managed PostgreSQL point-in-time recovery as one tracked switch, staging and verifying credentials on the restored database copy before fencing traffic.
gregale rollback my-api --to v41 --restore-databases
# Or restore only the database and switch the app without changing code
gregale postgres restore orders --name orders-0900 --point-in-time 2026-11-26T09:00:00Z --switch my-api
Key capabilities
Undoes release migrations automatically
Pass --restore-databases to restore each database migrated by undone releases back to the exact start timestamp of the earliest replaced release command.
Non-destructive copy semantics
Restores into a new database (<name>-before-v<revision>) so writes recorded after the restore point stay intact in the original database.
Verified phased cutover
Your current release keeps serving while Gregale restores the copy, stages credentials, and checks SQL connectivity before fencing and switching the app.
Data-only switch without code changes
When code is healthy and data is not, restore a managed PostgreSQL database to any timestamp in its 7-day window and switch the app in place.
Typical PaaS vs. Gregale
| Capability | Typical PaaS | Gregale |
|---|---|---|
| Coordinated code + DB rollback | Reverts image only; manual DB backup restore and rebind | One CLI command restores both to the migration boundary |
| Post-incident writes preservation | In-place restores risk overwriting recent rows | Creates a new restored copy and leaves original DB intact |
| Credential verification | App boots and discovers broken credentials live | Stages and verifies SQL credentials before fencing traffic |
Deep-dive guides (4)
Roll back a bad migration: code and database together
Rolling back code after a migration runs old code on the new schema. On Gregale, `gregale rollback --restore-databases` restores the managed PostgreSQL database to the moment before the migration as a new database and switches the app to it with the earlier code, keeping the original and its writes.
Canary deploys with automatic rollback
Every production release on Gregale goes to 1% of traffic first, moves up in stages on clean evidence, and rolls back on its own on 5xx errors, crash loops or a latency regression.
Stop Friday-night outages with deploy freezes, approvals and scheduled rollouts
Require signed-in human MFA approvals (`--approvals 2`), enforce recurring weekend or post-rollback deploy freezes (`--after-rollback 1h`), and build releases early to roll out automatically during quiet windows.
Stop microservice version drift with atomic project releases and release graphs
Preflight multi-service projects with `gregale deploy check --project`, pin compatible frontend, API, worker and queue versions with `X-Gregale-Release` and `__Host-gregale_release`, and opt into progressive whole-graph canaries.
Runnable starters & integrations (4)
Browse all templatesPython 3.13 · FastAPI · Postgres 17
Postgres Migration & Rollback Demo
FastAPI + managed PostgreSQL 17 starter demonstrating release.command migrations (MIGRATION_DATABASE_URL) and coordinated code + database rollback via gregale rollback --restore-databases.
Node 24 · Next.js 16 · Postgres 17
Next.js 16 + Postgres Starter
Next.js App Router with output: "standalone", pre-traffic SQL migrations, separate /healthz readiness check, and scale-to-zero MicroVMs.
Bun 1 · Hono · TypeScript · Postgres 17
Bun + Hono + Postgres Starter
TypeScript REST API using Bun, Hono, and postgres.js with release-command SQL migrations and managed PostgreSQL 17 suspension when idle.
GitHub Action · @v1
setup-gregale GitHub Action
Composite GitHub Action that installs the Gregale CLI, masks optional bearer credentials, and pairs with edge-rule-trace and deploy verification workflows.
Documentation references
Questions
- Does --restore-databases overwrite my existing PostgreSQL database?
No. Gregale restores a new database named <name>-before-v<revision> and rebinds the app to it. All writes that landed in the original database after the restore point remain untouched until you explicitly delete the old database.
- Can I restore a database and switch my app without rolling back application code?
Yes. Run gregale postgres restore <db> --name <new-name> --point-in-time <timestamp> --switch <app> to execute the same credential staging, fencing, drain, and switch flow while keeping the current code release.
- Is there brief downtime during a database-synced rollback?
While the database copy restores and SQL credentials are checked, the app continues serving. Gregale then fences traffic, drains active instances, switches the binding and release, and resumes the app (typically under a minute plus wake time).