@farhan0431/db-snap 0.3.9 → 0.3.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,139 @@
1
+ # dbsnap
2
+
3
+ **Database checkpoints for local development and AI coding agents.**
4
+
5
+ Save a snapshot before a migration or bulk edit, then restore the schema and
6
+ data if you need to roll back. Use dbsnap from your terminal or connect its
7
+ built-in MCP server to an AI assistant.
8
+
9
+ Supports **SQLite**, **PostgreSQL**, and **MySQL/MariaDB**. The npm package
10
+ bundles prebuilt binaries for Windows x64, macOS Intel and Apple Silicon, and
11
+ Linux x64 (glibc and musl) and ARM64 (glibc).
12
+
13
+ **MySQL/MariaDB restore is available for the original database.** Stop writers and scheduled events first. Restore is not atomic and requires a pinned safety snapshot. Interrupted restores must recover that snapshot before another restore.
14
+
15
+ ## Install
16
+
17
+ Requires Node.js 16 or later.
18
+
19
+ ```bash
20
+ npm install -g @farhan0431/db-snap
21
+ dbsnap --version
22
+ ```
23
+
24
+ Or run without a global install:
25
+
26
+ ```bash
27
+ npx -y @farhan0431/db-snap --help
28
+ ```
29
+
30
+ ## Quick start
31
+
32
+ Run these commands in the root of the project containing your development
33
+ database:
34
+
35
+ ```bash
36
+ dbsnap init
37
+ dbsnap status
38
+ dbsnap save "before migration"
39
+
40
+ # Run your migration or make changes here.
41
+
42
+ dbsnap list
43
+ dbsnap restore "before migration" # restores the selected snapshot
44
+ ```
45
+
46
+ `dbsnap init` detects `DATABASE_URL` or common SQLite paths. To choose a
47
+ database explicitly, use `dbsnap init --db ./prisma/dev.db`. Check the target
48
+ with `dbsnap status` before restoring: a restore changes the live database.
49
+
50
+ Snapshots and metadata live in `.dbsnap/` in your project. The directory is
51
+ added to `.gitignore` during initialization.
52
+
53
+ ## Use with an AI assistant
54
+
55
+ Register dbsnap as an MCP server in a compatible client. For example, add
56
+ the following to your project's `.cursor/mcp.json`:
57
+
58
+ ```json
59
+ {
60
+ "mcpServers": {
61
+ "dbsnap": {
62
+ "command": "dbsnap",
63
+ "args": ["mcp"]
64
+ }
65
+ }
66
+ }
67
+ ```
68
+
69
+ Restart your client and ask it to run `dbsnap_status` to confirm the database
70
+ before making changes. The server also exposes tools to create, list, restore,
71
+ and prune snapshots. It resolves the project from its working directory, so
72
+ start it in the project you want to protect.
73
+
74
+ Restore and prune are disabled by default in MCP. To enable them for a server
75
+ session, start it with `dbsnap mcp --allow-destructive`. Each operation requires
76
+ approval through an MCP client supporting elicitation; otherwise use the CLI.
77
+
78
+ `dbsnap init` also writes `.agents/skills/dbsnap/SKILL.md` in the project.
79
+ Whether that skill is loaded automatically depends on the AI client; the skill
80
+ file and the MCP server are separate integrations.
81
+
82
+ ## Commands
83
+
84
+ | Command | Purpose |
85
+ | --- | --- |
86
+ | `dbsnap init` | Bind the project to a database. |
87
+ | `dbsnap status` | Check the database and snapshot storage. |
88
+ | `dbsnap save [tag]` | Create a snapshot; the tag is optional. |
89
+ | `dbsnap list` | List snapshot IDs and tags. |
90
+ | `dbsnap restore [tag-or-id]` | Restore a snapshot; omit the selector for the latest. |
91
+ | `dbsnap rollback` | Restore the latest snapshot. |
92
+ | `dbsnap prune --keep 5` | Remove older snapshots and retain the newest five. |
93
+ | `dbsnap diff before after` | Compare SQLite snapshot schemas and table row counts. |
94
+ | `dbsnap pin <tag-or-id>` | Protect a snapshot from pruning; use `unpin` to remove protection. |
95
+
96
+ `dbsnap list --json` and `dbsnap status --json` provide machine-readable
97
+ output. SQLite `diff` does not compare individual row contents; PostgreSQL and
98
+ MySQL/MariaDB snapshot diffs are not currently supported.
99
+ Pinned snapshots survive `prune`, including `--all`.
100
+
101
+ ## Database requirements
102
+
103
+ | Database | Snapshot method | Requirements |
104
+ | --- | --- | --- |
105
+ | SQLite | Online backup and deduplicated chunks | No separate database client. |
106
+ | PostgreSQL | Server-side clone or `pg_dump` | Database creation privileges; PostgreSQL client tools for dump mode. |
107
+ | MySQL/MariaDB | Consistent logical dump | Compatible `mysql`/`mysqldump` or MariaDB client tools in `PATH`; transactional tables for consistent dumps. |
108
+
109
+ PostgreSQL server-side clones are stored on the database server. Use dump mode
110
+ when the snapshot needs to survive removal of that server's data volume.
111
+ For dump save and restore, install `pg_dump` and `pg_restore` matching the
112
+ PostgreSQL server's major version. Mismatched tools are rejected before restore.
113
+
114
+ ## Safety
115
+
116
+ - MCP permits SQLite and loopback database hosts only. The CLI also permits
117
+ private-network targets by default. A local target is not necessarily safe.
118
+ - Project binding checks that the current target matches the recorded database.
119
+ - Restore checks SQLite chunks and dump artifacts before applying them and, by default,
120
+ creates a safety snapshot first. If that snapshot cannot be created, restore
121
+ stops; the CLI has an explicit option to skip it.
122
+ - A PostgreSQL server-side clone has a metadata fingerprint, not a content
123
+ checksum. dbsnap checks that the clone exists before restore.
124
+ - PostgreSQL restore is not atomic; an interruption can require manual
125
+ recovery. Clone and staged dump restores journal their cutover.
126
+ - PostgreSQL network connections require verified TLS. Set `DBSNAP_PG_CA_CERT`
127
+ to a trusted CA PEM file if needed; use `DBSNAP_PG_TLS=verify-full` to require
128
+ TLS on loopback connections as well.
129
+
130
+ dbsnap is intended for development workflows. Keep independent backups for
131
+ data you cannot afford to lose.
132
+
133
+ ## Links
134
+
135
+ - [Repository and full documentation](https://github.com/farhan0431/db-snap)
136
+ - [MCP installation guide](https://github.com/farhan0431/db-snap/blob/main/INSTALL.md)
137
+ - [Report an issue](https://github.com/farhan0431/db-snap/issues)
138
+
139
+ MIT license.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farhan0431/db-snap",
3
- "version": "0.3.9",
3
+ "version": "0.3.11",
4
4
  "description": "Instant physical database time-machine and MCP server for AI coding agents — git commit/checkout for your local database, powered by Rust.",
5
5
  "license": "MIT",
6
6
  "bin": {