fix(db): make deploy's dry-run clone schema-only by default - #55
Open
nipunappri[bot] wants to merge 1 commit into
Open
nipunappri[bot] wants to merge 1 commit into
nipunappri[bot] wants to merge 1 commit into
Conversation
Yasirunet
self-requested a review
September 24, 2026 12:20
`db deploy` cloned the full target database — schema and every row — into a throwaway local container before running its DDL dry-run, then dropped it. On any database with real data this dominated the command's runtime, billed egress on every deploy, and put production rows on developer machines. The dry-run verifies that committed DDL applies cleanly, which only needs the target's structure. Default to `pg_dump --schema-only` and add `--with-data` for migrations whose risk lives in the data (adding NOT NULL or UNIQUE to a populated column, type narrowing, backfills). `schemaOnly` is now a required parameter on `cloneDatabase` and `cloneDatabaseViaContainer`. The silent `= false` default is how this happened: `db start` remembered to pass `true`, `db deploy` did not. Requiring it means no future caller can get row data by omission. Also warn when `--with-data` is used that seeds run against a clone already holding the target's rows and may conflict on existing keys.
nipunappri
Bot
force-pushed
the
fix/deploy-schema-only-clone
branch
from
September 24, 2026 12:22
b47f0f2 to
6a94bda
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Branch:
fix/deploy-schema-only-clone→mainSummary
postkit db deploycloned the entire target database, including every row, into a throwaway local container before running its DDL dry-run — then dropped it. On any database with real data this dominated the command's runtime.pg_dump --schema-onlyby default.--with-datato opt back in for migrations whose risk lives in the data rather than the schema.Changes
db deployclones structure only by default.deploy.tsnow passesschemaOnly: !options.withDatato both clone paths (host anddocker exec). Previously it passed nothing and inherited the= falsedefault, whiledb startcorrectly passedtrue.--with-datatodb deploy(modules/db/index.ts) for cases where the migration's risk is in the data: addingNOT NULLorUNIQUEto a populated column, type narrowing, backfills.schemaOnlya required parameter oncloneDatabaseandcloneDatabaseViaContainer. The silent default is exactly how this bug happened — one caller remembered, one didn't. Requiring it means no future caller can pull row data by omission. Typechecking confirmedstartanddeploywere the only production callers.--with-datathat seeds run as part of the dry-run against a clone that already holds the target's rows, so seed inserts may conflict on existing keys.cli/docs/db.md,CLAUDE.md) updated — the old behavior was documented as deliberate, so those passages needed rewriting, not just extending.Type of Change
Test Plan
npm run test) — 382 passed, 31 filesnpm run build)npx tsc --noEmit)db deploy --helpdocuments--with-dataas opt-inschemaOnly: true/falseargument paths are both still coverednpm run test:e2e) — not run locally (needs Docker/testcontainers); please confirm in CIBreaking Changes
postkit db deployno longer clones the target's row data during its dry-run.cli/docs/db.mdpreviously documented the full-data clone as intentional — "it still clones full data, since it's specifically verifying real migrations against realistic data before they touch production." That rationale is real, so the capability is preserved behind--with-datarather than removed.The trade-off: a migration that would only fail against real rows (e.g.
ALTER COLUMN ... SET NOT NULLon a column containing nulls) will now pass the dry-run and fail on the target instead. Anyone relying on the old behavior should add--with-datato their deploy invocation. Worth calling out in release notes.The public signatures of
cloneDatabase/cloneDatabaseViaContainergained a required parameter. Both are internal to the CLI, so this only affects in-repo callers.