Introducing Starpac: desired-state database delivery
Database schemas are easier to reason about when the repository describes the state you want, rather than only the sequence of changes that happened along the way.
Starpac is the home of *pac (pronounced “starpac”), a family of focused desired-state database tools:
- pgpac for PostgreSQL;
- d1pac for Cloudflare D1 and SQLite.
If you know DACPAC, the mental model will feel familiar: package a declarative database model, compare it to a target, then publish the delta.
Keep the desired schema in Git
A Starpac project points to ordinary SQL files that describe tables, indexes, views, and other database objects as they should exist. The CLI builds those files into a portable package: .pgpkg for pgpac or .d1pkg for d1pac.
The package can then be compared with a live database:
pgpac plan \
--package out/Application.pgpkg \
--connection "postgres://user:pass@localhost:5432/appdb"d1pac plan \
--package out/Application.d1pkg \
--database application \
--script deployment.sqlInstead of maintaining a growing chain of migration scripts, you can read the schema that the application expects today. Starpac works out the operations required to bring the target database to that state.
Review before applying
Planning and applying are separate steps. A plan can be rendered as text, JSON, or SQL, making it suitable for local review and CI automation.
Destructive operations are explicit. If a deployment would remove schema or data, the apply command stops unless the caller deliberately opts in. This keeps the desired-state workflow convenient without hiding consequential changes.
Although pgpac and d1pac share a workflow, each tool retains engine-native behavior. PostgreSQL and D1 are not forced through a generic database abstraction.
Install the tool you need
Both CLIs are available from the Magnus Opera Homebrew tap:
brew tap magnusopera/tap
brew install pgpacor:
brew tap magnusopera/tap
brew install d1pacVisit the Starpac website for the pgpac and d1pac quickstarts, command references, and versioned documentation. The project is open source on GitHub.