Tell generated apps not to delete the Builder-managed Drizzle scaffold - #396
Closed
armgjoka wants to merge 1 commit into
Closed
Tell generated apps not to delete the Builder-managed Drizzle scaffold#396armgjoka wants to merge 1 commit into
armgjoka wants to merge 1 commit into
Conversation
A Fusion project restructured from the single-app starter into an apps/* monorepo and its cleanup commit deleted drizzle/ and drizzle.config.ts while leaving the database block in builder.config.json pointing at the old location. Builder's schema-merge resolver locates the schema through database.schemaDir, so it had nothing to reconcile. The ai-services resolver now recovers an unambiguously relocated setup and skips cleanly instead of hard-failing. That turns a blocked merge into a silently disabled gate: a migration that drops a production column can merge unnoticed. Nothing in a generated project said the scaffold was load-bearing, and the guidance that existed lived in drizzle/START_HERE.md, inside the directory it was meant to protect. Add a "Builder-managed database files" section to the generated AGENTS.md naming the four managed paths, the silent consequence of deleting them, and the requirement to move database.schemaDir in the same change. It also states that schemaDir is a single path, so a monorepo with more than one app-owned drizzle.config.ts gets no check at all and should say so rather than pick one. Reaches newly created projects only; existing projects are covered by the resolver fix.
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.
Why
A Fusion project restructured from the single-app starter into an
apps/*monorepo. The cleanup commit deleted the rootdrizzle/directory anddrizzle.config.tsbut left thedatabaseblock inbuilder.config.jsonpointing at the old location.Builder runs a schema-merge resolver on every branch merge for any project with a provisioned database:
drizzle-kit generateto reconcile migrations both branches added independently, then a scan of the generated SQL forDROP TABLE/DROP COLUMN/ALTER COLUMN ... TYPEthat blocks the merge if it finds any. It locates the schema throughdatabase.schemaDirin rootbuilder.config.json.With the directory gone, that resolver broke and blocked every merge on the project with an unreadable error. That half is fixed in
ai-services(packages/dev-tools/cli/resolve-schema-merge.ts) — it now recovers a relocated setup when that is unambiguous, and skips cleanly instead of hard-failing when it cannot.Which changes the stakes rather than removing them. Deleting the scaffold no longer produces a loud error, it silently disables the destructive-migration gate — a migration that drops a production column can now merge unnoticed. That is what this rule is for.
Nothing in a generated project said those files were load-bearing. The guidance that did exist lived in
drizzle/START_HERE.md, inside the directory it was supposed to protect, and was deleted along with it.What changes
One section added to the generated root
AGENTS.md(the file loaded unconditionally each session;CLAUDE.mdin a generated project is a one-line pointer to it):builder.config.json,drizzle.config.ts,drizzle/schema.ts,drizzle/migrations/database.schemaDirin the same change when the repo restructures, with the JSON shapeschemaDiris a single path, so a monorepo where more than one app has its owndrizzle.config.tsgets no check at all — say so rather than silently picking onedatabaseblock if the app genuinely no longer uses a databaseThe section is folded into the existing
## Source Changesreplacement rather than added as a seconduniqueReplace. A separate replacement splits that block, making itstonon-contiguous, and the patch then fails on re-apply — CI's idempotency check caught that, and there is now a comment recording the constraint.Also:
assertPatchedassertions so the section cannot silently drop out of a future sync, plus the overlayREADME.md/VERIFICATION.mdentries.Verification
Ran the same sequence as
verify-starter-patch.yml:origin/maintree with--source-root— passes, section present exactly once, existing patched text intactgit diff --exit-codeand a cleanstatus --porcelain— idempotentThen the
EnableDatabasepath against the patchedmaintree, usingscaffoldDrizzleDatabasefromai-services:The scaffold still writes correctly and skips exactly what the starter already ships, confirming the four paths the rule names are the ones actually present.
Finally, reproduced the incident against
resolveDrizzleSetupon that tree: intact it resolvesconfigPath,schemaFilePath,migrationsDirandjournalPath; after deletingdrizzle/anddrizzle.config.tswith thedatabaseblock left in place it returnsnull, whichresolveSchemaMergereports as success with nothing to reconcile. That is the silent skip the section warns about.Scope
Newly created projects only — Fusion clones the starter at project-create time and there is no retrofit path. Existing projects are covered by the
ai-servicesresolver fix.