Schema in. Migration out.
Go CLI tool for PostgreSQL schema management via Prisma schemas and Goose migrations.
- PostgreSQL introspection → Generate Prisma schemas from existing databases
- Prisma schema parsing → Understand your data models
- Schema diff engine → Detect changes between schema versions
- Goose migration generation → Create SQL migrations automatically
- Destructive change detection → Warn about data loss risks
Build from source:
git clone https://github.com/phathdt/dryft.git
cd dryft
make build
# or: go build -o dryft ./cmd/dryftOr install to $GOPATH/bin:
make installInitialize a new dryft project:
dryft initPull schema from an existing PostgreSQL database:
dryft db pullCreate a migration from schema changes:
dryft migration create "add user table"dryft init- Initialize configuration and state directorydryft db pull- Introspect PostgreSQL and generate Prisma schemadryft migration create <name>- Generate Goose migration from schema diffdryft schema diff- Preview changes between current and previous schemasdryft validate- Validate Prisma schema syntax and semantics
Create a .dryft.yaml file in your project root (or run dryft init):
database:
provider: postgresql
url: ${DATABASE_URL}
schema:
file: prisma/schema.prisma
naming:
fields: camelCase
tables: PascalCase
migration:
directory: migrations
format: goose
naming: timestamp
goose:
version_table: goose_db_versionSee .dryft.yaml.example for full configuration options.
dryft generates incremental migrations by comparing your Prisma schema against migration history (100% offline):
Migration generation is 100% offline and does NOT require database connection:
# First migration (empty migrations/ directory)
dryft migration create initial
# → Creates full schema (CREATE TABLE)
# Incremental migrations (existing migrations/ files)
dryft migration create add_user_bio
# → Creates incremental changes (ALTER TABLE)Workflow:
- Parse existing migrations in
migrations/directory - Build virtual schema from migration history
- Compare with current
schema.prisma - Generate incremental SQL (ALTER instead of CREATE)
Database connection is ONLY needed for db pull:
# Introspect existing database → generate schema.prisma
dryft db pullAfter db pull, all future migrations are generated offline from migration history.
# Run tests (skip integration tests)
make test-short
# Run all tests including integration
make test
# Format code
make fmt
# Run static analysis
make vet
# Run linter
make lint
# Development workflow (fmt + vet + test + build)
make devWe welcome contributions! Before submitting a pull request, please ensure:
- All tests pass:
make test - Code is formatted:
make fmt - No lint errors:
make lint - Test coverage ≥85%
See CONTRIBUTING.md for detailed guidelines.
All PRs must pass these automated checks:
✅ Format - Code properly formatted with gofmt
✅ Lint - No linting errors (golangci-lint)
✅ Vet - Pass go vet analysis
✅ Build - Code compiles successfully
✅ Unit Tests - All unit tests pass
✅ Integration Tests - All integration tests pass
✅ Coverage - Maintain ≥85% test coverage
✅ v0.1 MVP Complete - All 8 phases implemented and tested
- ✅ CLI framework and configuration
- ✅ Internal schema model (normalized IR)
- ✅ PostgreSQL introspection
- ✅ Prisma schema writer with relation fields
- ✅ Prisma schema parser
- ✅ Schema diff engine with dependency ordering
- ✅ PostgreSQL SQL generator
- ✅ Goose migration formatter
- ✅ 57 integration tests passing (testcontainers)
See MVP_COMPLETE.md for detailed summary.
Current MVP has the following limitations:
@@indexnot generated in migrations (#21) - Index definitions are parsed but not included in SQL output- Prisma relation fields skipped (#10) -
@relationsyntax is parsed with warnings but not converted to FK constraints
- No automatic column rename detection (#15) - Renames appear as DROP+ADD (potential data loss)
- Enum drops disabled (#12) - Safety feature pending dependency checks
- Single schema only (#14) - Only
publicschema introspected - Views not supported (#13) - Database views are ignored
- Advanced env var expansion (#19) - Only basic
${VAR}supported - go-migrate format (#18) - Only Goose format currently
- Deferrable foreign keys (#16) - Advanced PostgreSQL feature
- MySQL support (#17) - PostgreSQL only for now
See GitHub Issues for complete list and progress.
- Fix
@@indexgeneration in migrations (#21) - Support Prisma
@relationfields and FK constraints (#10) - Add end-to-end migration tests with PostgreSQL (#23)
- Implement automatic column rename detection (#15)
- Enum drop operations with safety checks (#12)
- Multi-schema PostgreSQL support (#14)
- PostgreSQL views introspection and migration (#13)
- MySQL database provider support (#17)
- go-migrate format output (#18)
- Advanced constraint features (deferrable FKs, etc.)
MIT