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 testinggraft checkout clean-state# Run tests against the branchpytest tests/ -n auto# Reset for the next rungraft 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).
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 buggit checkout maingraft checkout main# Database is back to main's state, payment-v2 changes isolated
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 featurenpm run test:e2e# If something went wrong, roll back in secondsgraft rollback
# Seed the databaseseedling generate --count 50000 --seed 42 --db "$DATABASE_URL"# Snapshot the seeded stategraft commit -m "load test baseline (50K rows)"# Run load testk6 run load-test.js# Reset to exact same state for the next rungraft checkout baseline