db-rollback

Restores a PostgreSQL database to a previous snapshot or executes a rollback script.

3|Updated Feb 7, 2026
One-click install
npx skills add https://github.com/gabrielnsmnto/kord-aios --skill db-rollback-gabrielnsmnto
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: db-rollback
Source: https://github.com/gabrielnsmnto/kord-aios/tree/main/src/features/builtin-skills/kord-aios/database/db-rollback
Command: npx skills add https://github.com/gabrielnsmnto/kord-aios --skill db-rollback-gabrielnsmnto

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Reverting a database schema after a failed or breaking migration is risky and error-prone. This Skill provides a guarded, step-by-step rollback workflow for Supabase/PostgreSQL databases with automatic safety snapshots, locking, and validation. ## Core Features & Use Cases - Guarded Rollback Execution: Requires explicit user confirmation, creates an emergency snapshot before any change, and acquires an advisory lock to prevent concurrent operations. - Multiple Rollback Strategies: Supports snapshot restore, explicit rollback scripts, and forward-fix migrations, with a decision matrix to choose the right approach. - Post-Rollback Validation: Verifies schema object counts, runs sanity checks, and creates a post-rollback snapshot for auditability. - Use Case: A migration breaks your application in staging. Run the rollback against the pre-migration snapshot, then follow up with smoke tests and an RLS audit to confirm the schema is healthy. ## Quick Start Ask the agent to roll back the database to a specific snapshot file, for example: roll back the database to supabase/snapshots/20251026_pre_migration.sql.

Frequently Asked Questions about db-rollback

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I roll back a PostgreSQL database to a previous snapshot?▼

Provide the path to a snapshot SQL file created with pg_dump. The workflow validates the file, creates an emergency snapshot of the current state, acquires an advisory lock, then replays the snapshot with psql in a single pass.

What is the difference between snapshot restore and a rollback script?▼

Snapshot restore replays a full pg_dump schema file and is best for reverting entire migrations. A rollback script is a hand-written SQL file that surgically drops or alters specific objects, giving precise control but requiring manual maintenance.

When should I use a forward fix instead of a database rollback?▼

Use a forward fix when rollback risks data corruption, when the database is in production with active users, or when only a minor bug exists in a function. A corrective migration preserves history and avoids data loss.

Does the rollback process protect against concurrent database operations?▼

Yes. It acquires a PostgreSQL advisory lock using pg_try_advisory_lock before executing, and aborts if another operation holds the lock. The lock is released after the rollback and post-rollback snapshot complete.

What happens if the rollback fails partway through?▼

The workflow automatically attempts to restore the emergency snapshot created before execution. If that restore also fails, it reports that the database may be inconsistent and flags the need for manual intervention.

Why does a rollback fail with 'relation already exists' errors?▼

The snapshot file is missing DROP IF EXISTS statements, so old objects conflict with recreated ones. Regenerate the snapshot using pg_dump with the --clean and --if-exists flags to fix this.