Repository navigation
Conversation
`rtk prisma migrate status` printed "Migrations: 0 applied, 0 pending" against a database with six applied migrations, and the same summary would appear for a project with none. filter_migrate_status counted lines containing the substring "applied", which Prisma does not print on a successful run: it prints "N migrations found in <path>" followed by "Database schema is up to date!". No Prisma version emits the shape that counter expects. Two more consequences of the same heuristic: - "Following migration have not yet been applied:" contains "applied", so a pending migration was scored as an applied one. - filter_migrate_deploy reported "2 migration(s) deployed" for a run that applied three, having counted the two summary sentences rather than the per-migration "Applying migration `name`" lines. Parse the documented output shapes instead, and return the raw output whenever the text does not match one of them (drift, failed migrations, shadow database errors). A status summary that cannot be trusted is worse than no summary at all: never_worse compares sizes only, so it cannot catch a parser that is confidently wrong. Test fixtures are verbatim captures from Prisma 7.8.0 against PostgreSQL 16, not hand-written approximations. Co-Authored-By: Claude Opus 5 <[email protected]>
|
|
WoldenMn
force-pushed
the
fix/prisma-migrate-status-zero-counts
branch
from
October 10, 2026 21:26
0c5354a to
a905882
Compare
Collaborator
|
Thanks for the contribution! Before we can review and merge this, the CLA needs to be signed. The CLAassistant bot left the link above, it only takes a minute. Once it's signed we'll pick the review up. |
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.
Problem
rtk prisma migrate statusreportsMigrations: 0 applied, 0 pendingagainst a database that has migrations applied.Reproduced on Prisma 7.8.0 + PostgreSQL 16, in a real project (6 migrations) and in an isolated throwaway project (2 migrations):
filter_migrate_statuscounts lines containing the substringapplied:Prisma does not print either word on a successful run — it prints
N migrations found in <path>andDatabase schema is up to date!. This is not a Prisma 7 regression: no Prisma version emits the shape this counter expects, so the summary has always been0 applied, 0 pendingon a healthy database.Two related consequences of the same heuristic:
Following migration have not yet been applied:containsapplied, so a pending migration is scored as an applied one.filter_migrate_deployreported2 migration(s) deployedfor a run that applied three, having counted the two summary sentences instead of the per-migrationApplying migration \name`` lines.Scope, measured rather than assumed: the filter only runs on success, and Prisma exits 1 when migrations are pending, so rtk falls through to raw passthrough in that case and the pending migration stays visible. Exit codes are propagated correctly. The damage is a confidently wrong count, not a hidden pending migration — but a count of
0on a healthy project is the kind of output an agent will quote as fact.never_worsecannot help here: it compares token counts, never correctness.Fix
Parse the documented output shapes, and fall back to the raw output whenever the text does not match one of them — drift, failed migrations, shadow-database errors. A summary that cannot be trusted is worse than no summary.
Tests
10 new tests. Fixtures are verbatim captures from Prisma 7.8.0 against PostgreSQL 16, not hand-written approximations. Two of them are explicit regression guards:
status_never_claims_zero_when_migrations_existstatus_does_not_count_the_pending_header_as_appliedBoth were confirmed non-vacuous by mutation: forcing the count back to
0makes them fail, and reverting makes them pass.cargo teston the full crate is2583 passed; 3 failed. The three failures are inhooks::rewrite_cmd::tests::unattestable_passthroughand are pre-existing ondevelop(6f0b0ca) — verified by stashing this patch and re-running, and by moving%APPDATA%\rtk\config.tomlaside to rule out local config. They are unrelated to this change; happy to open a separate issue if they are not already known.Environment: Windows 11,
stable-x86_64-pc-windows-msvc.