Skip to content

miseya/dbsnap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dbsnap

Automatic database row snapshots before DML execution. A transaction-like rollback mechanism for PostgreSQL testing and debugging.

How It Works

dbsnap runs as a wire protocol proxy between your application and PostgreSQL. It transparently intercepts DML queries (INSERT, UPDATE, DELETE), snapshots affected rows, and provides undo capability through a terminal UI.

Your App (:5433) → dbsnap (proxy) → PostgreSQL (:5432)

Undo Logic

Original Query Undo Action
INSERT Deletes the inserted rows
UPDATE Restores rows to their previous values
DELETE Re-inserts the deleted rows

Usage

# Start dbsnap proxy + TUI (defaults to localhost:5432)
dbsnap

# Or specify a custom PostgreSQL address
dbsnap --pg myhost:5432

# Custom proxy listen port
dbsnap --listen :5433 --pg myhost:5432

# Point your app at the proxy instead of PostgreSQL directly
DATABASE_URL="postgres://user:pass@localhost:5433/mydb"

The proxy automatically detects the user and database from the client's connection — no need to specify a full connection string.

Keybindings

Key Action
↑/↓ Navigate history
u Undo selected query
tab Switch panels
q Quit

Tech Stack

  • Go — core language
  • Bubble Tea — terminal UI framework
  • pg_query_go — PostgreSQL SQL parser
  • pgx — PostgreSQL driver

License

MIT

About

Undo any row changes easily!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages