|
1 | 1 | # DeepDiff DB |
2 | 2 |
|
3 | 3 | [](https://github.com/iamvirul/deepdiff-db/actions/workflows/ci.yml) |
| 4 | +[](https://github.com/iamvirul/deepdiff-db/actions/workflows/security.yml) |
4 | 5 | [](https://github.com/iamvirul/deepdiff-db/releases/latest) |
5 | 6 | [](https://codecov.io/gh/iamvirul/deepdiff-db) |
6 | 7 | [](https://goreportcard.com/report/github.com/iamvirul/deepdiff-db) |
@@ -46,6 +47,7 @@ DeepDiff DB makes the entire process deterministic, reviewable, and safe by: |
46 | 47 | - **Enhanced error handling** - Rich error messages with actionable suggestions |
47 | 48 | - **Streaming large datasets** - Keyset-paginated batch hashing keeps memory bounded at any table size |
48 | 49 | - **Parallel table hashing** - Hash multiple tables concurrently with configurable worker pool |
| 50 | +- **Git-like versioning** - Commit diff snapshots, browse history, compare versions, generate rollback SQL |
49 | 51 |
|
50 | 52 | ### Safety Features |
51 | 53 |
|
@@ -479,6 +481,61 @@ Continues from a previous session by loading existing resolutions. |
479 | 481 | **Output Files:** |
480 | 482 | - `resolutions.json` - Saved resolution decisions |
481 | 483 |
|
| 484 | +### version |
| 485 | + |
| 486 | +Git-like versioning for database diffs. Stores schema and data diff snapshots as commits, enabling history browsing, inter-version comparison, and rollback SQL generation — all without a live database connection. |
| 487 | + |
| 488 | +```bash |
| 489 | +deepdiffdb version <subcommand> [flags] |
| 490 | +``` |
| 491 | + |
| 492 | +#### Subcommands |
| 493 | + |
| 494 | +| Subcommand | Description | |
| 495 | +|---|---| |
| 496 | +| `version init` | Initialise a `.deepdiffdb/` repository in the current directory | |
| 497 | +| `version commit` | Run a full diff and store the result as a new commit | |
| 498 | +| `version log` | Show the commit history from most recent to oldest | |
| 499 | +| `version diff <h1> <h2>` | Compare schema evolution between two commits | |
| 500 | +| `version rollback <hash>` | Generate rollback SQL to undo the changes in a commit | |
| 501 | +| `version branch [<name>]` | List branches, or create a new one | |
| 502 | +| `version checkout <branch>` | Switch to a branch | |
| 503 | +| `version tree` | Show ASCII commit graph for all branches | |
| 504 | + |
| 505 | +#### Example Workflow |
| 506 | + |
| 507 | +```bash |
| 508 | +# Initialise once per project |
| 509 | +deepdiffdb version init |
| 510 | +
|
| 511 | +# Commit a baseline snapshot |
| 512 | +deepdiffdb version commit --config deepdiffdb.config.yaml --message "V1: baseline" --author "Alice" |
| 513 | +
|
| 514 | +# Create a feature branch and switch to it |
| 515 | +deepdiffdb version branch feature |
| 516 | +deepdiffdb version checkout feature |
| 517 | +
|
| 518 | +# After applying schema changes to dev, commit on the feature branch |
| 519 | +deepdiffdb version commit --config deepdiffdb.config.yaml --message "V2: add reviews table" --author "Bob" |
| 520 | +
|
| 521 | +# Switch back to main and commit a hotfix |
| 522 | +deepdiffdb version checkout main |
| 523 | +deepdiffdb version commit --config deepdiffdb.config.yaml --message "V2: hotfix index" --author "Alice" |
| 524 | +
|
| 525 | +# Browse history with an ASCII branch graph |
| 526 | +deepdiffdb version tree |
| 527 | +
|
| 528 | +# See what changed between two commits |
| 529 | +deepdiffdb version diff <hash_v1> <hash_v2> |
| 530 | +
|
| 531 | +# Generate rollback SQL for a commit |
| 532 | +deepdiffdb version rollback --out rollback.sql <hash_v2> |
| 533 | +``` |
| 534 | + |
| 535 | +**Storage:** Commits are stored as zlib-compressed objects in `.deepdiffdb/objects/<2-char>/<62-char>` (Git-style fanout, content-addressable by SHA-256). Branch tips live in `.deepdiffdb/refs/heads/<name>`; HEAD is a symbolic ref (`ref: refs/heads/main`). Add `.deepdiffdb/` to your `.gitignore` or commit it to share history with your team. |
| 536 | + |
| 537 | +**Rollback SQL:** Each commit stores full schema snapshots, so rollback SQL can be generated at any time without a live database. Destructive operations (DROP TABLE, DROP COLUMN) are commented out by default — identical safety behaviour to `schema-migrate`. |
| 538 | + |
482 | 539 | ## Usage Examples |
483 | 540 |
|
484 | 541 | ### Basic Workflow |
|
0 commit comments