fix(codegen): write prettier-stable schema snapshot - #43985
Open
kitlangton wants to merge 1 commit into
Open
Conversation
No blocking issues found. Nit: packages/core/script/migration.ts:200-203 — |
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.
What
Regenerating a database migration reformats the entire checked-in
packages/core/schema.json, burying the real change in hundreds of lines of array-reflow noise. This applies the same treatment #23228 gave the OpenAPI documents: format the generated snapshot in place so regeneration diffs contain only real schema changes.Before / After
Before:
bun script/migration.tsraw-copies drizzle'ssnapshot.json, which emits every array multi-line. The checked-in snapshot is prettier-styled (short arrays collapsed), so adding a single column reflows every"columns": [...]array in the file — a 3-column addition produced a 206-line diff, ~170 of them formatting churn.After: the snapshot is piped through prettier (
parser: "json",printWidth: 120) before writing. The formatter is a byte-for-byte no-op on the current checked-in snapshot, and a test column addition now produces a 14-line diff.How
packages/core/script/migration.ts: replaces thefs.copyFileof drizzle's snapshot with a formattedBun.write, adding aformatJsonhelper mirroring the existingformatTypescript.--checkfeeds the snapshot to drizzle as a parsed baseline and never byte-compares it, so formatting is invisible to validation.Testing
schema.json(byte-identical input/output).bun script/migration.ts --checkandbun typecheckclean frompackages/core.