Repository navigation
feat(cli): consolidate db verify and remove db schema-verify - #243
Conversation
Factor ~120 duplicated lines between executeDbVerifyCommand and executeDbSchemaOnlyVerifyCommand into focused helpers: renderVerifyHeader, resolveVerifyPaths, resolveVerifySetup, createVerifyClient, and wrapVerifyError. Also fix node:path -> pathe in e2e tests and add happy-path test for --schema-only --strict mode. Made-with: Cursor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughUpdated CLI verification surface: replaced Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
@prisma-next/runtime-executor
@prisma-next/sql-runtime
@prisma-next/extension-paradedb
@prisma-next/extension-pgvector
@prisma-next/postgres
@prisma-next/sql-orm-client
@prisma-next/contract-authoring
@prisma-next/contract-ts
@prisma-next/ids
@prisma-next/psl-parser
@prisma-next/cli
@prisma-next/emitter
@prisma-next/eslint-plugin
@prisma-next/migration-tools
@prisma-next/vite-plugin-contract-emit
@prisma-next/sql-contract
@prisma-next/sql-errors
@prisma-next/sql-operations
@prisma-next/sql-schema-ir
@prisma-next/sql-contract-psl
@prisma-next/sql-contract-ts
@prisma-next/sql-contract-emitter
@prisma-next/family-sql
@prisma-next/sql-kysely-lane
@prisma-next/sql-lane-query-builder
@prisma-next/sql-relational-core
@prisma-next/sql-lane
@prisma-next/target-postgres
@prisma-next/adapter-postgres
@prisma-next/driver-postgres
@prisma-next/core-control-plane
@prisma-next/core-execution-plane
@prisma-next/config
@prisma-next/contract
@prisma-next/operations
@prisma-next/plan
@prisma-next/utils
commit: |
| # Summary | ||
|
|
||
| Consolidate database verification onto `prisma-next db verify` and remove the parallel `prisma-next db schema-verify` command. `db verify` remains correctness-first by default (marker check + tolerant schema verification), keeps `--shallow` as an explicit marker-only escape hatch, and absorbs schema-only / strict structural checks under flags so there is one verb for all verification workflows. |
There was a problem hiding this comment.
Here's the plan.
TODO: delete this after review.
There was a problem hiding this comment.
Actionable comments posted: 10
🧹 Nitpick comments (3)
packages/1-framework/3-tooling/cli/recordings/ascii/greenfield-setup/09-db-verify-json.ascii (1)
1-1: Remove environment-specific locale warnings from committed recording output.These lines are shell-environment noise rather than CLI output, and they make the JSON recording harder to read. Please set locale explicitly in the recording harness and regenerate this fixture.
Also applies to: 33-33, 65-65, 97-97, 129-129, 161-161, 193-193, 196-196
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/1-framework/3-tooling/cli/recordings/ascii/greenfield-setup/09-db-verify-json.ascii` at line 1, The committed ASCII recording contains environment-specific locale warning lines ("bash: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8): No such file or directory"); update the recording harness to export a stable locale (for example set LC_ALL=C.UTF-8 and LANG=C.UTF-8 or unset LC_ALL/LANG to a known value) before spawning shells used by the harness, then regenerate the fixture file packages/1-framework/3-tooling/cli/recordings/ascii/greenfield-setup/09-db-verify-json.ascii (and the other affected recordings at the listed positions) so the warning lines are removed from the committed output. Ensure the change is made in the test/recording bootstrap code (the recording harness initialization) so all subsequent recordings no longer include the locale warnings.packages/1-framework/3-tooling/cli/recordings/ascii/drift-phantom/02-db-verify-shallow-pass.ascii (1)
1-1: Stabilize recordings by filtering locale warnings.These
setlocalelines are host-environment noise and create avoidable snapshot churn. Prefer normalizing locale in the recorder/harness so fixtures only capture CLI output.Also applies to: 33-33, 65-65, 97-97, 129-129, 161-161, 193-193
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/1-framework/3-tooling/cli/recordings/ascii/drift-phantom/02-db-verify-shallow-pass.ascii` at line 1, Tests are brittle because the recorder captures host locale warnings ("bash: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8): No such file or directory"); update the recording harness (the CLI recorder/fixture normalizer) to strip or normalize that exact warning string (and its variants) from captured stdout/stderr (e.g., add a filter in the recorder's normalizeOutput / sanitizeRecording path) so the ascii fixtures (drift-phantom/02-db-verify-shallow-pass.ascii and the other listed snapshots) no longer include locale noise.docs/CLI Style Guide.md (1)
138-141: Document incompatibledb verifyflag combinations.Consider adding that
--shallowcannot be combined with--schema-onlyor--strict(usage error / exit code 2), while--schema-only --strictis valid. That keeps this guide aligned with actual CLI behavior.📝 Proposed doc tweak
- - `--shallow` performs marker-only verification. - - `--schema-only` skips marker checks and verifies only that the live schema satisfies the contract. - - `--strict` makes schema verification fail on unmanaged extra schema elements. + - `--shallow` performs marker-only verification. + - `--schema-only` skips marker checks and verifies only that the live schema satisfies the contract. + - `--strict` makes schema verification fail on unmanaged extra schema elements. + - `--shallow` is incompatible with `--schema-only` and `--strict` (usage error, exit code `2`). + - `--schema-only --strict` is supported.As per coding guidelines "Keep docs current (READMEs, rules, links) - see
.cursor/rules/doc-maintenance.mdc."🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/CLI` Style Guide.md around lines 138 - 141, Update the "db verify" flag docs to state that the CLI disallows combining --shallow with --schema-only or --strict (these combinations should be described as a usage error returning exit code 2), while explicitly noting that --schema-only can be used together with --strict; mention this directly alongside the existing bullets for Default, --shallow, --schema-only, and --strict so users see compatible vs incompatible flag combinations for the db verify command.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/1-framework/3-tooling/cli/README.md`:
- Line 110: Update the README entry for the prisma-next db verify synopsis to
explicitly document rejected flag combinations: state that using --shallow
together with --schema-only or with --strict is invalid and results in a
usage/config error (PN-CLI-4012) with exit code 2; update the Options section
(and the nearby duplicate descriptions at the later reference) to call out these
exact combinations and their error code/exit behavior so users don’t assume
they’re supported.
In
`@packages/1-framework/3-tooling/cli/recordings/ascii/direct-update/03-db-update-apply.ascii`:
- Line 1: The VHS recordings include locale-related warnings; update the
runVhs() invocation so the spawned vhs command is run with LANG=C or LC_ALL=C in
its environment to suppress setlocale warnings. Locate the runVhs() function and
modify the environment passed to the vhs execution (process spawn/options or env
merging) to include LANG=C (or LC_ALL=C) while preserving existing env vars,
then regenerate the affected recordings so snapshots no longer contain the
locale warning noise.
In
`@packages/1-framework/3-tooling/cli/recordings/ascii/direct-update/04-db-update-noop.ascii`:
- Around line 34-35: Several step markers in the ASCII recording use the
malformed pattern "> No-op # ..." which gets treated as a shell command; update
the marker formatting to the correct form "> # No-op — ..." wherever the string
"> No-op #" appears (e.g., the occurrences around the comment lines currently
producing "bash: No-op: command not found") so the marker is a comment token
rather than a command, then regenerate the tape/fixture to ensure the ASCII
recording and SVG render correctly.
In
`@packages/1-framework/3-tooling/cli/recordings/ascii/direct-update/05-db-verify.ascii`:
- Line 1: The golden recording contains host-specific locale noise: the line
starting with "bash: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8):
No such file or directory" should be removed; regenerate the fixture under a
stable locale (export LC_ALL or LANG to a known value before running the
commands) or update the recorder/post-processor to filter out stderr lines
matching that exact warning regex so the stored .ascii artifacts no longer
include the locale warning across all affected recordings.
In
`@packages/1-framework/3-tooling/cli/recordings/ascii/drift-phantom/03-db-introspect-diverged.ascii`:
- Line 200: Recording shows Postgres at 127.0.0.1:5432 which conflicts with the
harness default port 5433; update either the recording or the harness to match.
Re-record the ascii fixture using the harness default (ensure
DEFAULT_DATABASE_URL in record.ts points to port 5433 and docker-compose.yaml
exposes 5433:5432) or, if 5432 is the new intended standard, update
DEFAULT_DATABASE_URL in record.ts and docker-compose.yaml to use 5432 and
regenerate the recordings so the recorded database URL and the harness default
are consistent. Ensure the change is applied to DEFAULT_DATABASE_URL (record.ts)
and the docker-compose service port mapping to prevent future snapshot
mismatches.
In
`@packages/1-framework/3-tooling/cli/recordings/ascii/drift-phantom/04-db-update-recovery.ascii`:
- Around line 34-35: The transcript includes prompt lines like "> Recovery #
re-add missing column, re-sign marker ..." that are being interpreted as shell
commands; edit each such prompt line (e.g., the literal string "Recovery #
re-add missing column, re-sign marker" and the other occurrences around lines
66-67, 98-99, 130-131, 162-163, 194-195) so the comment indicator appears
immediately after the prompt (e.g., change "> Recovery # ..." to "> # Recovery
..." or "> # Recovery — ..." ), ensuring the shell prompt is followed by a shell
comment token so these headings are treated as comments and do not produce
"bash: Recovery: command not found".
In
`@packages/1-framework/3-tooling/cli/recordings/ascii/drift-phantom/05-db-verify-schema-only-pass.ascii`:
- Line 34: The recorded fixture header "# Schema-only verification passes after
recovery [schema restored, marker matches contract]" claims a pass but the
recorded result block contains the failure message "Database schema does not
satisfy contract", causing inconsistency; fix by either (A) updating the header
to reflect a failing scenario to match the recorded result, or (B) regenerate
the recorded result block so it shows a successful verification outcome (no
"Database schema does not satisfy contract" error) to match the header. Locate
the header string and the result block containing "Database schema does not
satisfy contract" in this fixture (and apply the same consistency fix to the
other similar fixtures mentioned) and ensure the title and recorded outcome
align.
In
`@packages/1-framework/3-tooling/cli/recordings/ascii/drift-stale-marker/01-db-verify-fail.ascii`:
- Line 34: Rename the awkward scenario title string "fails Verify marker hash
does not match new contract [initialized with base, contract swapped to v2]" to
a clearer format like "Verify fails: marker hash does not match new contract
[initialized with base, contract swapped to v2]"; search for the identical title
occurrences elsewhere in the file (the other lines with the same wording) and
apply the same replacement so all scenario titles read "Verify fails: ..." for
consistent, more readable phrasing.
In
`@packages/1-framework/3-tooling/cli/recordings/ascii/drift-stale-marker/03-db-update-recovery.ascii`:
- Around line 34-35: The line starting with "> Recovery # apply pending change,
update marker [base schema, v2 contract]" is being interpreted by bash as a
command ("Recovery") and causing "command not found" errors; change the marker
so it is a shell-safe comment or non-executable marker (for example replace the
leading "> Recovery" with a shell comment like "# Recovery — apply pending
change, update marker [base schema, v2 contract]" or any other line that begins
with "#" or another non-executable prefix) and apply the same change
consistently to all similar markers in the file to prevent bash from attempting
to execute them.
In
`@packages/1-framework/3-tooling/cli/recordings/ascii/greenfield-setup/04-db-init-idempotent.ascii`:
- Line 34: Update the step label string "re-run Idempotent expects no changes
[initialized, marker matches contract]" to a clearer phrasing such as
"Idempotent re-run expects no changes [initialized, marker matches contract]"
wherever it appears; search for the exact snippet "re-run Idempotent expects no
changes" in the ASCII recording and replace each occurrence (including repeats
at the same pattern) so the wording reads "Idempotent re-run expects no changes
..." to improve readability while preserving the bracketed status text.
---
Nitpick comments:
In `@docs/CLI` Style Guide.md:
- Around line 138-141: Update the "db verify" flag docs to state that the CLI
disallows combining --shallow with --schema-only or --strict (these combinations
should be described as a usage error returning exit code 2), while explicitly
noting that --schema-only can be used together with --strict; mention this
directly alongside the existing bullets for Default, --shallow, --schema-only,
and --strict so users see compatible vs incompatible flag combinations for the
db verify command.
In
`@packages/1-framework/3-tooling/cli/recordings/ascii/drift-phantom/02-db-verify-shallow-pass.ascii`:
- Line 1: Tests are brittle because the recorder captures host locale warnings
("bash: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8): No such file
or directory"); update the recording harness (the CLI recorder/fixture
normalizer) to strip or normalize that exact warning string (and its variants)
from captured stdout/stderr (e.g., add a filter in the recorder's
normalizeOutput / sanitizeRecording path) so the ascii fixtures
(drift-phantom/02-db-verify-shallow-pass.ascii and the other listed snapshots)
no longer include locale noise.
In
`@packages/1-framework/3-tooling/cli/recordings/ascii/greenfield-setup/09-db-verify-json.ascii`:
- Line 1: The committed ASCII recording contains environment-specific locale
warning lines ("bash: warning: setlocale: LC_ALL: cannot change locale
(C.UTF-8): No such file or directory"); update the recording harness to export a
stable locale (for example set LC_ALL=C.UTF-8 and LANG=C.UTF-8 or unset
LC_ALL/LANG to a known value) before spawning shells used by the harness, then
regenerate the fixture file
packages/1-framework/3-tooling/cli/recordings/ascii/greenfield-setup/09-db-verify-json.ascii
(and the other affected recordings at the listed positions) so the warning lines
are removed from the committed output. Ensure the change is made in the
test/recording bootstrap code (the recording harness initialization) so all
subsequent recordings no longer include the locale warnings.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 61156db9-a36a-4c2f-b8d5-b662f5384809
⛔ Files ignored due to path filters (39)
packages/1-framework/3-tooling/cli/recordings/svgs/direct-update/01-contract-emit-v2.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/direct-update/02-db-update-dry-run.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/direct-update/03-db-update-apply.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/direct-update/04-db-update-noop.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/direct-update/05-db-verify.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/drift-missing-marker/01-db-verify-fail.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/drift-missing-marker/02-db-schema-verify-fail.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/drift-missing-marker/02-db-verify-schema-only-fail.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/drift-missing-marker/03-db-introspect-empty.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/drift-missing-marker/04-db-init-recovery.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/drift-missing-marker/05-db-verify-pass.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/drift-phantom/01-db-verify-fail.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/drift-phantom/01-db-verify-false-positive.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/drift-phantom/02-db-schema-verify-fail.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/drift-phantom/02-db-verify-shallow-pass.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/drift-phantom/03-db-introspect-diverged.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/drift-phantom/04-db-update-recovery.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/drift-phantom/05-db-schema-verify-pass.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/drift-phantom/05-db-verify-schema-only-pass.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/drift-stale-marker/01-db-verify-fail.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/drift-stale-marker/02-db-schema-verify-fail.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/drift-stale-marker/02-db-verify-schema-only-fail.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/drift-stale-marker/03-db-update-recovery.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/drift-stale-marker/04-db-verify-pass.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/greenfield-setup/01-contract-emit.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/greenfield-setup/02-db-init-dry-run.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/greenfield-setup/03-db-init.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/greenfield-setup/04-db-init-idempotent.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/greenfield-setup/05-db-verify.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/greenfield-setup/06-db-schema-verify.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/greenfield-setup/06-db-verify-schema-only.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/greenfield-setup/07-db-schema-verify-strict.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/greenfield-setup/07-db-verify-strict.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/greenfield-setup/08-db-introspect.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/greenfield-setup/09-db-verify-json.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/greenfield-setup/10-db-schema-verify-json.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/greenfield-setup/10-db-verify-schema-only-json.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/test/__snapshots__/help.snapshot.test.ts.snapis excluded by!**/*.snapprojects/db-verify-consolidation/spec.mdis excluded by!projects/**
📒 Files selected for processing (56)
docs/CLI Style Guide.mddocs/architecture docs/adrs/ADR 154 - Component-owned database dependencies.mdpackages/1-framework/1-core/migration/control-plane/src/errors.tspackages/1-framework/1-core/migration/control-plane/test/errors.test.tspackages/1-framework/3-tooling/cli/CLI_RECORDING.mdpackages/1-framework/3-tooling/cli/README.mdpackages/1-framework/3-tooling/cli/package.jsonpackages/1-framework/3-tooling/cli/recordings/ascii/direct-update/01-contract-emit-v2.asciipackages/1-framework/3-tooling/cli/recordings/ascii/direct-update/02-db-update-dry-run.asciipackages/1-framework/3-tooling/cli/recordings/ascii/direct-update/03-db-update-apply.asciipackages/1-framework/3-tooling/cli/recordings/ascii/direct-update/04-db-update-noop.asciipackages/1-framework/3-tooling/cli/recordings/ascii/direct-update/05-db-verify.asciipackages/1-framework/3-tooling/cli/recordings/ascii/drift-missing-marker/01-db-verify-fail.asciipackages/1-framework/3-tooling/cli/recordings/ascii/drift-missing-marker/02-db-verify-schema-only-fail.asciipackages/1-framework/3-tooling/cli/recordings/ascii/drift-missing-marker/03-db-introspect-empty.asciipackages/1-framework/3-tooling/cli/recordings/ascii/drift-missing-marker/04-db-init-recovery.asciipackages/1-framework/3-tooling/cli/recordings/ascii/drift-missing-marker/05-db-verify-pass.asciipackages/1-framework/3-tooling/cli/recordings/ascii/drift-phantom/01-db-verify-fail.asciipackages/1-framework/3-tooling/cli/recordings/ascii/drift-phantom/02-db-verify-shallow-pass.asciipackages/1-framework/3-tooling/cli/recordings/ascii/drift-phantom/03-db-introspect-diverged.asciipackages/1-framework/3-tooling/cli/recordings/ascii/drift-phantom/04-db-update-recovery.asciipackages/1-framework/3-tooling/cli/recordings/ascii/drift-phantom/05-db-verify-schema-only-pass.asciipackages/1-framework/3-tooling/cli/recordings/ascii/drift-stale-marker/01-db-verify-fail.asciipackages/1-framework/3-tooling/cli/recordings/ascii/drift-stale-marker/02-db-verify-schema-only-fail.asciipackages/1-framework/3-tooling/cli/recordings/ascii/drift-stale-marker/03-db-update-recovery.asciipackages/1-framework/3-tooling/cli/recordings/ascii/drift-stale-marker/04-db-verify-pass.asciipackages/1-framework/3-tooling/cli/recordings/ascii/greenfield-setup/01-contract-emit.asciipackages/1-framework/3-tooling/cli/recordings/ascii/greenfield-setup/02-db-init-dry-run.asciipackages/1-framework/3-tooling/cli/recordings/ascii/greenfield-setup/03-db-init.asciipackages/1-framework/3-tooling/cli/recordings/ascii/greenfield-setup/04-db-init-idempotent.asciipackages/1-framework/3-tooling/cli/recordings/ascii/greenfield-setup/05-db-verify.asciipackages/1-framework/3-tooling/cli/recordings/ascii/greenfield-setup/06-db-verify-schema-only.asciipackages/1-framework/3-tooling/cli/recordings/ascii/greenfield-setup/07-db-schema-verify-strict.asciipackages/1-framework/3-tooling/cli/recordings/ascii/greenfield-setup/07-db-verify-strict.asciipackages/1-framework/3-tooling/cli/recordings/ascii/greenfield-setup/08-db-introspect.asciipackages/1-framework/3-tooling/cli/recordings/ascii/greenfield-setup/09-db-verify-json.asciipackages/1-framework/3-tooling/cli/recordings/ascii/greenfield-setup/10-db-verify-schema-only-json.asciipackages/1-framework/3-tooling/cli/recordings/config.tspackages/1-framework/3-tooling/cli/src/cli.tspackages/1-framework/3-tooling/cli/src/commands/db-introspect.tspackages/1-framework/3-tooling/cli/src/commands/db-schema-verify.tspackages/1-framework/3-tooling/cli/src/commands/db-verify.tspackages/1-framework/3-tooling/cli/src/utils/formatters/help.tspackages/1-framework/3-tooling/cli/src/utils/formatters/verify.tspackages/1-framework/3-tooling/cli/test/utils/suggest-command.test.tspackages/1-framework/3-tooling/cli/tsdown.config.tspackages/1-framework/3-tooling/cli/vitest.config.tstest/integration/test/cli-journeys/README.mdtest/integration/test/cli-journeys/brownfield-adoption.e2e.test.tstest/integration/test/cli-journeys/drift-marker.e2e.test.tstest/integration/test/cli-journeys/drift-schema.e2e.test.tstest/integration/test/cli-journeys/greenfield-setup.e2e.test.tstest/integration/test/cli.db-schema-verify.e2e.test.tstest/integration/test/cli.db-verify.e2e.test.tstest/integration/test/fixtures/cli/cli-e2e-test-app/fixtures/db-schema-verify/prisma-next.config.with-db.tstest/integration/test/utils/journey-test-helpers.ts
💤 Files with no reviewable changes (2)
- packages/1-framework/3-tooling/cli/recordings/ascii/greenfield-setup/07-db-schema-verify-strict.ascii
- packages/1-framework/3-tooling/cli/package.json
There was a problem hiding this comment.
Left you a handful of comments on cosmetic issues. Let's avoid using indirect or jargon-y terms in our user-facing descriptions. Let's also avoid introducing the term "phantom drift" in the codebase and instead describe the problem directly: the marker doesn't match the schema, i.e. "invalid marker" or "stale marker"
Your agent has also replaced all mentions of schema-verify with verify --schema-only - many of these can be deleted, they're redundant
| @@ -156,7 +156,7 @@ export function createDbIntrospectCommand(): Command { | |||
| 'Inspect the database schema', | |||
| 'Reads the live database schema and displays it as a tree structure. This command\n' + | |||
| 'does not check the schema against your contract - it only shows what exists in\n' + | |||
| 'the database. Use `db verify` or `db schema-verify` to compare against your contract.', | |||
| 'the database. Use `db verify` or `db verify --schema-only` to compare against your contract.', | |||
There was a problem hiding this comment.
| 'the database. Use `db verify` or `db verify --schema-only` to compare against your contract.', | |
| 'the database. Use `db verify` to compare against your contract.', |
| 'Schema verification skipped because --shallow was provided. Run `prisma-next db schema-verify` to detect structural drift.', | ||
| 'Schema verification skipped because --shallow was provided. Run `prisma-next db verify --schema-only` to detect structural drift.', |
There was a problem hiding this comment.
Let's avoid terms like "structural drift". Suggestion:
'Schema verification skipped because --shallow was provided'
| 'Verifies the database marker first, then runs structural schema verification to catch drift\n' + | ||
| 'such as manual DDL changes. Use `--shallow` for marker-only verification, `--schema-only`\n' + | ||
| 'to skip marker checks and inspect only the live schema, and `--strict` to fail on extra\n' + | ||
| 'schema elements when schema verification runs.', |
There was a problem hiding this comment.
Same here, avoid "structural drift", "phantom drift" etc and speak in accessible terms:
'Verifies the database marker first, then checks the database schema matches your contract. Use `--shallow` for marker-only verification, `--schema-only`\n' +
'to skip marker checks and inspect only the live schema, and `--strict` to fail if the database includes elements not present in the contract',
| │ the database. Use \`db verify\` or \`db schema-verify\` to compare against your | ||
| │ contract. | ||
| │ the database. Use \`db verify\` or \`db verify --schema-only\` to compare against | ||
| │ your contract. |
There was a problem hiding this comment.
Your agent has adopted a pattern of mentioning --schema-only anywhere that schema-verify was previously mentioned. Just say "use db verify", that's enough
| @@ -129,17 +129,26 @@ exports[`help text snapshots > formats db verify help 1`] = ` | |||
| │ --config <path> Path to prisma-next.config.ts | |||
| │ --shallow Skip structural schema verification and only check the | |||
| │ database marker | |||
| │ --schema-only Skip marker verification and only check whether the live | |||
| │ schema satisfies the contract | |||
| │ --strict Strict mode: extra schema elements cause failures | |||
There was a problem hiding this comment.
| │ --strict Strict mode: extra schema elements cause failures | |
| │ --strict Strict mode:schema elements not present in the contract are considered an error |
| │ Verifies the database marker first, then runs structural schema verification | ||
| │ to catch drift | ||
| │ such as manual DDL changes. Use \`--shallow\` for marker-only verification, | ||
| │ \`--schema-only\` | ||
| │ to skip marker checks and inspect only the live schema, and \`--strict\` to fail | ||
| │ on extra | ||
| │ schema elements when schema verification runs. |
There was a problem hiding this comment.
See my phrasing above - this is indirect and relies on "drift", a term many people won't be familiar with
| | `drift-missing-marker` | No marker in database, recovery via `db init` | | ||
| | `drift-stale-marker` | Marker hash mismatch after contract change, recovery via `db update` | | ||
| | `drift-phantom` | Manual DDL drift undetected by marker, caught by `db schema-verify` | | ||
| | `drift-phantom` | Manual DDL drift detected by `db verify`; `db verify --shallow` shows the marker-only escape hatch | |
There was a problem hiding this comment.
Let's avoid introducing "phantom drift" into codebase vocabulary. "invalid marker" or "stale marker" eg would be a better description
| Options: | ||
| - `--db <url>`: Database connection string (optional; defaults to `config.db.connection` if set) | ||
| - `--config <path>`: Optional. Path to `prisma-next.config.ts` (defaults to `./prisma-next.config.ts` if present) | ||
| - `--shallow`: Skip structural schema verification and only check the database marker |
There was a problem hiding this comment.
| - `--shallow`: Skip structural schema verification and only check the database marker | |
| - `--signature-only`: Skip structural schema verification and only check the database marker |
or
| - `--shallow`: Skip structural schema verification and only check the database marker | |
| - `--marker-only`: Skip structural schema verification and only check the database marker |
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
packages/1-framework/3-tooling/cli/recordings/ascii/drift-invalid-marker/05-db-verify-schema-only-pass.ascii (1)
34-34:⚠️ Potential issue | 🟠 MajorRegenerate this tape: “passes after recovery” conflicts with recorded failure.
Line 34 says schema-only verification passes after recovery, but Line 214 records
PN-SCHEMA-0001failure. That conflicts with the configured step intent inpackages/1-framework/3-tooling/cli/recordings/config.ts:432-440(dbState: schema restored, marker matches contract). Please regenerate this recording with the correct recovered DB state (or update scenario metadata if failure is intended).Based on learnings: In
packages/1-framework/3-tooling/cli/recordings/ascii/**, treat VHS-generated.asciirecordings as machine-generated artifacts and do not manually edit them.Also applies to: 214-214
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/1-framework/3-tooling/cli/recordings/ascii/drift-invalid-marker/05-db-verify-schema-only-pass.ascii` at line 34, The ASCII recording "05-db-verify-schema-only-pass.ascii" has mismatched outcome text ("passes after recovery") versus the recorded PN-SCHEMA-0001 failure; regenerate the VHS recording so the recorded tape reflects the intended recovered DB state, or if the failure was intended, update the scenario metadata's dbState and intent in the config entry that defines the scenario (refer to the config key dbState and the scenario around the entry that sets marker/contract expectations) so the .ascii output and PN-SCHEMA-0001 result align; do not manually edit the .ascii file—re-run the recorder to produce a consistent tape and update the scenario metadata accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/1-framework/3-tooling/cli/README.md`:
- Line 267: Update the README entry that currently reads "Exit code 1 with
schema verification payload: Schema does not match the contract after marker
verification passed" to remove the over-constraining phrase and clarify that
this exit code and payload can occur regardless of marker verification (for
example when running "db verify --schema-only"); locate the exact line
containing that sentence and reword it to say something like "Exit code 1 with
schema verification payload: Schema does not match the contract (this can occur
even when marker verification is not performed, e.g. using 'db verify
--schema-only')" so the docs accurately reflect both code paths.
---
Duplicate comments:
In
`@packages/1-framework/3-tooling/cli/recordings/ascii/drift-invalid-marker/05-db-verify-schema-only-pass.ascii`:
- Line 34: The ASCII recording "05-db-verify-schema-only-pass.ascii" has
mismatched outcome text ("passes after recovery") versus the recorded
PN-SCHEMA-0001 failure; regenerate the VHS recording so the recorded tape
reflects the intended recovered DB state, or if the failure was intended, update
the scenario metadata's dbState and intent in the config entry that defines the
scenario (refer to the config key dbState and the scenario around the entry that
sets marker/contract expectations) so the .ascii output and PN-SCHEMA-0001
result align; do not manually edit the .ascii file—re-run the recorder to
produce a consistent tape and update the scenario metadata accordingly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: e4d8327d-11e3-4d5b-8bd1-12e5adf7e4fc
⛔ Files ignored due to path filters (15)
packages/1-framework/3-tooling/cli/recordings/svgs/direct-update/05-db-verify.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/drift-invalid-marker/01-db-verify-fail.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/drift-invalid-marker/02-db-verify-marker-only-pass.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/drift-invalid-marker/03-db-introspect-diverged.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/drift-invalid-marker/04-db-update-recovery.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/drift-invalid-marker/05-db-verify-schema-only-pass.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/drift-missing-marker/01-db-verify-fail.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/drift-missing-marker/05-db-verify-pass.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/drift-phantom/04-db-update-recovery.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/drift-stale-marker/01-db-verify-fail.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/drift-stale-marker/04-db-verify-pass.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/greenfield-setup/05-db-verify.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/recordings/svgs/greenfield-setup/07-db-verify-strict.svgis excluded by!**/*.svgpackages/1-framework/3-tooling/cli/test/__snapshots__/help.snapshot.test.ts.snapis excluded by!**/*.snapprojects/db-verify-consolidation/spec.mdis excluded by!projects/**
📒 Files selected for processing (25)
docs/CLI Style Guide.mdpackages/1-framework/3-tooling/cli/CLI_RECORDING.mdpackages/1-framework/3-tooling/cli/README.mdpackages/1-framework/3-tooling/cli/recordings/ascii/direct-update/05-db-verify.asciipackages/1-framework/3-tooling/cli/recordings/ascii/drift-invalid-marker/01-db-verify-fail.asciipackages/1-framework/3-tooling/cli/recordings/ascii/drift-invalid-marker/02-db-verify-marker-only-pass.asciipackages/1-framework/3-tooling/cli/recordings/ascii/drift-invalid-marker/03-db-introspect-diverged.asciipackages/1-framework/3-tooling/cli/recordings/ascii/drift-invalid-marker/04-db-update-recovery.asciipackages/1-framework/3-tooling/cli/recordings/ascii/drift-invalid-marker/05-db-verify-schema-only-pass.asciipackages/1-framework/3-tooling/cli/recordings/ascii/drift-missing-marker/01-db-verify-fail.asciipackages/1-framework/3-tooling/cli/recordings/ascii/drift-missing-marker/05-db-verify-pass.asciipackages/1-framework/3-tooling/cli/recordings/ascii/drift-stale-marker/01-db-verify-fail.asciipackages/1-framework/3-tooling/cli/recordings/ascii/drift-stale-marker/04-db-verify-pass.asciipackages/1-framework/3-tooling/cli/recordings/ascii/greenfield-setup/05-db-verify.asciipackages/1-framework/3-tooling/cli/recordings/ascii/greenfield-setup/07-db-verify-strict.asciipackages/1-framework/3-tooling/cli/recordings/ascii/greenfield-setup/09-db-verify-json.asciipackages/1-framework/3-tooling/cli/recordings/config.tspackages/1-framework/3-tooling/cli/src/commands/db-introspect.tspackages/1-framework/3-tooling/cli/src/commands/db-verify.tspackages/1-framework/3-tooling/cli/src/control-api/client.tspackages/1-framework/3-tooling/cli/src/utils/formatters/verify.tspackages/1-framework/3-tooling/cli/test/help.snapshot.test.tstest/integration/test/cli-journeys/README.mdtest/integration/test/cli-journeys/drift-schema.e2e.test.tstest/integration/test/cli.db-verify.e2e.test.ts
✅ Files skipped from review due to trivial changes (9)
- packages/1-framework/3-tooling/cli/recordings/ascii/drift-invalid-marker/03-db-introspect-diverged.ascii
- packages/1-framework/3-tooling/cli/recordings/ascii/drift-invalid-marker/02-db-verify-marker-only-pass.ascii
- docs/CLI Style Guide.md
- packages/1-framework/3-tooling/cli/recordings/ascii/direct-update/05-db-verify.ascii
- packages/1-framework/3-tooling/cli/recordings/ascii/greenfield-setup/05-db-verify.ascii
- packages/1-framework/3-tooling/cli/CLI_RECORDING.md
- packages/1-framework/3-tooling/cli/recordings/ascii/greenfield-setup/07-db-verify-strict.ascii
- packages/1-framework/3-tooling/cli/recordings/ascii/drift-stale-marker/01-db-verify-fail.ascii
- packages/1-framework/3-tooling/cli/recordings/ascii/drift-invalid-marker/04-db-update-recovery.ascii
🚧 Files skipped from review as they are similar to previous changes (5)
- packages/1-framework/3-tooling/cli/recordings/ascii/drift-stale-marker/04-db-verify-pass.ascii
- packages/1-framework/3-tooling/cli/recordings/ascii/drift-missing-marker/01-db-verify-fail.ascii
- packages/1-framework/3-tooling/cli/recordings/config.ts
- packages/1-framework/3-tooling/cli/recordings/ascii/drift-missing-marker/05-db-verify-pass.ascii
- packages/1-framework/3-tooling/cli/recordings/ascii/greenfield-setup/09-db-verify-json.ascii
- Remove merge conflict markers in Migration System docs (kept the codec-hooks-driven paragraph as the most complete version) - Delete orphaned db-schema-verify.ts (removed in main by PR #243, incorrectly preserved during rebase)
- Remove merge conflict markers in Migration System docs (kept the codec-hooks-driven paragraph as the most complete version) - Delete orphaned db-schema-verify.ts (removed in main by PR #243, incorrectly preserved during rebase)
closes TML-2085
Walkthrough —
db verifyconsolidationIntent
Consolidate all database verification onto
prisma-next db verifyso engineers learn one command. The paralleldb schema-verifycommand is removed; its marker-independent structural verification becomesdb verify --schema-only, and its strict mode becomesdb verify --strict.Key snippet
Mode resolution and flag validation
Change map
retryCommandoption, updated fix text--schema-only --stricthappy-path tests--schema-only,--strict--schema-only--schema-only--shallow,--schema-only,--strictretryCommandpreserves flags--schema-only,--strictin help; noschema-verifyThe story
Introduce a mode discriminant: The
DbVerifyModetype ('full' | 'shallow' | 'schema-only') andresolveDbVerifyMode()make the mode explicit and validate flag combinations before any I/O. Invalid combinations producePN-CLI-4012with exit code 2.Add
--schema-onlyexecution path: A newexecuteDbSchemaOnlyVerifyCommand()function bypasses marker verification and calls onlyclient.schemaVerify(). It reuses the existingformatSchemaVerifyOutput/formatSchemaVerifyJsonformatters, so TTY and JSON output stay identical to whatdb schema-verifyproduced.Thread
--strictthrough full mode:executeDbVerifyCommandnow passesoptions.stricttoclient.schemaVerify()instead of hard-codingfalse. The formatter shows(strict)or(tolerant)in the verification mode label.Delete
db schema-verify: The command file, import incli.ts, package export, build entry, test config entry, help docs URL, and suggest-command candidate are all removed.Migrate all call sites: Journey tests replace
runDbSchemaVerify(ctx)withrunDbVerify(ctx, ['--schema-only']). Error messages and docs replacedb schema-verifywithdb verify --schema-only. Recordings config renames slugs and commands.Improve retry hints:
errorDatabaseConnectionRequiredgains aretryCommandoption so that the fix text reflects the exact flags the user provided (e.g.,Runprisma-next db verify --schema-only --strict --db ``).Extract shared setup boilerplate: The ~120 lines of duplicated config-loading / contract-reading / connection-resolution / error-handling between
executeDbVerifyCommandandexecuteDbSchemaOnlyVerifyCommandare factored into focused helpers:resolveVerifyPaths,resolveVerifySetup,createVerifyClient,renderVerifyHeader, andwrapVerifyError.Behavior changes & evidence
db verifydefault mode now reports strict/tolerant in output: Before, the mode label wasmarker + schema. After, it isfull (marker + schema, tolerant)orfull (marker + schema, strict).--strictis now available ondb verify, so the output must disambiguate.--shallowwarning text directs todb verify --schema-onlyinstead ofdb schema-verify: Before → "Runprisma-next db schema-verify". After → "Runprisma-next db verify --schema-only".db schema-verifyno longer exists.Adds
db verify --schema-onlyas a new mode: Runs structural schema verification without marker checks. Reuses existingschemaVerify()call and formatters.db schema-verifyfor brownfield adoption, corrupt-marker diagnosis, and missing-marker triage.Adds
db verify --strictfor full mode: Before,db verifyalways calledschemaVerify({ strict: false }). After, it passesoptions.strict, sodb verify --strictcatches extra schema elements.db schema-verify --strictfor strict structural checks.--shallow --schema-onlyand--shallow --strictrejected with exit code 2: Before, these combinations were not possible (separate commands). After, they are caught eagerly.db schema-verifyis removed (no behavior change — removal): The command, its export, build entry, test file, fixture, and all references are deleted.schema-verifyError fix text updated across control-plane:
errorMigrationPlanningFailednow suggestsdb verify --schema-onlyinstead ofdb schema-verify.Compatibility / migration / risk
prisma-next db schema-verifyno longer exists. Any external script using it will fail. This is intentional per the spec (NFR-3: no backward-compatibility scaffolding). The repo has no external consumers.client.verify()andclient.schemaVerify()are unchanged.db signis unaffected.Follow-ups / open questions
pnpm lint:deps: Should be run before merge to confirm no dead references remain in the dependency graph.Non-goals / intentionally out of scope
client.schemaVerify()or family-level schema verification APIsdb sign,db update, ordb introspectbehavior (only guidance text updated)db schema-verifySummary by CodeRabbit
New Features
Changes
Documentation