Skip to main content

Use Cases

QA Test Data Reset

QA testers need a known database state before each test run. With traditional setups, this means SQL dump/restore cycles that take 5-20 minutes.
# Create a clean branch before testing
graft checkout clean-state

# Run tests against the branch
pytest tests/ -n auto

# Reset for the next run
graft checkout clean-state
Each checkout takes ~3-5 seconds regardless of database size, because the tree is materialized from the object pool (only changed files are touched).

Feature Branch Isolation

Switch database state as you switch code branches. No migration-rollback dance.
# On feature branch "payment-v2"
graft checkout feature-payment-v2
# Database now has the tables and data for payment-v2

# Switch back to main to investigate a bug
git checkout main
graft checkout main
# Database is back to main's state, payment-v2 changes isolated

Pre-Migration Testing

Before running a destructive migration, snapshot the current state:
graft commit -m "before payment_methods migration"

# Run the migration...
psql -d myapp -f migrations/20260604_add_payment_methods.sql

# Test the new feature
npm run test:e2e

# If something went wrong, roll back in seconds
graft rollback

Load Testing Baseline

Create a consistent baseline for load tests:
# Seed the database
seedling generate --count 50000 --seed 42 --db "$DATABASE_URL"

# Snapshot the seeded state
graft commit -m "load test baseline (50K rows)"

# Run load test
k6 run load-test.js

# Reset to exact same state for the next run
graft checkout baseline

CI Pipeline Database State

In CI, restore a known database state before running tests:
jobs:
  test:
    steps:
      - uses: actions/checkout@v4
      - name: Restore database state
        run: graft checkout test-fixtures
      - name: Run tests
        run: go test ./...
Graft’s exit codes (0 = success, 1 = failure) integrate naturally with CI pipelines.

Experiment Safely

Try schema changes or data transformations in isolation, knowing you can always revert:
graft checkout unsafe-experiment
# Drop tables, rename columns, corrupt data — it's isolated
graft verify unsafe-experiment
# ✗ Integrity FAILED — dump the experiment
graft delete unsafe-experiment
graft checkout main
# Back to safety