fix(db): ship flattened dist/schema.prisma for external consumers#2677
Merged
Conversation
The native v7 multi-file schema refactor (c58045f) removed the legacy combine-schemas step that produced a single-file schema in dist/. That worked inside the monorepo (apps read prisma/schema/ directly), but broke external consumers like comp-private's enterprise-api/cx-dashboard/ framework-editor/trust apps, which all run cp ../../node_modules/@trycompai/db/dist/schema.prisma prisma/schema.prisma at build time. The 2.0.1 publish was the first to consume the post- refactor build, and shipped without dist/schema.prisma — breaking every consumer's db:getschema script and blocking SALE-49's comp-private PR. Add scripts/build-dist-schema.js: concatenates prisma/schema/*.prisma (schema.prisma generator+datasource first, models alphabetically after) into dist/schema.prisma during build. Output matches the v2.0.0 shape exactly so consumers don't need to change. Wire into the build script after tsc. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
|
🎉 This PR is included in version 3.34.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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.
Summary
@trycompai/db@2.0.1shipped withoutdist/schema.prisma, breaking everydb:getschemascript across comp-private apps (enterprise-api,cx-dashboard,framework-editor,trust). All fourcp .../@trycompai/db/dist/schema.prisma prisma/schema.prismacalls now fail because the file isn't in the tarball.The regression was introduced by the v7 multi-file refactor (c58045f, April 2) which removed the legacy
combine-schemas.jsstep. That worked inside the monorepo (apps readprisma/schema/directly), but external consumers were never re-tested because we hadn't published since the refactor. 2.0.1 was the first publish post-refactor — and it broke comp-private's CI.Fix
packages/db/scripts/build-dist-schema.js: deterministically concatenatesprisma/schema/*.prisma(schema.prismafirst for the generator + datasource block, models alphabetically after) intodist/schema.prisma. Matches the v2.0.0 published shape exactly, so consumers don't change.Wired into
packages/db'sbuildscript aftertscso the file lands in the published tarball.Verification
bun run buildlocally → tarball will now includedist/schema.prisma(47 model files concatenated, ~one block per source file).bunx prisma validate --schema=dist/schema.prisma✅ valid.// ===== <file>.prisma =====separators, same model bodies.Test plan
releasePR auto-cuts →@trycompai/db@2.0.2publishes@trycompai/dbin comp-private apps →bun run db:getschemasucceeds → CI green🤖 Generated with Claude Code
Summary by cubic
Restore a single-file Prisma schema for
@trycompai/dbby buildingdist/schema.prismafrom the v7 multi-file sources. This fixes brokendb:getschemascripts for external consumers and unblocks comp-private CI (SALE-49).scripts/build-dist-schema.jsto concatenateprisma/schema/*.prismaintodist/schema.prisma(base schema first, others sorted) matching the v2.0.0 format.buildso the file is published;prisma validatepasses and comp-privatedb:getschemaruns succeed.Written for commit 602aad7. Summary will update on new commits.