Skip to content

fix(db): ship flattened dist/schema.prisma for external consumers#2677

Merged
Marfuen merged 1 commit into
mainfrom
mariano/fix-db-dist-schema
Apr 25, 2026
Merged

fix(db): ship flattened dist/schema.prisma for external consumers#2677
Marfuen merged 1 commit into
mainfrom
mariano/fix-db-dist-schema

Conversation

@Marfuen
Copy link
Copy Markdown
Contributor

@Marfuen Marfuen commented Apr 25, 2026

Summary

@trycompai/db@2.0.1 shipped without dist/schema.prisma, breaking every db:getschema script across comp-private apps (enterprise-api, cx-dashboard, framework-editor, trust). All four cp .../@trycompai/db/dist/schema.prisma prisma/schema.prisma calls 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.js step. That worked inside the monorepo (apps read prisma/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 concatenates prisma/schema/*.prisma (schema.prisma first for the generator + datasource block, models alphabetically after) into dist/schema.prisma. Matches the v2.0.0 published shape exactly, so consumers don't change.

Wired into packages/db's build script after tsc so the file lands in the published tarball.

Verification

  • Ran bun run build locally → tarball will now include dist/schema.prisma (47 model files concatenated, ~one block per source file).
  • bunx prisma validate --schema=dist/schema.prisma ✅ valid.
  • Diff-checked against the v2.0.0 file in npm: same generator block, same datasource, same // ===== <file>.prisma ===== separators, same model bodies.

Test plan

  • Merge → release PR auto-cuts → @trycompai/db@2.0.2 publishes
  • Bump @trycompai/db in comp-private apps → bun run db:getschema succeeds → CI green
  • Unblocks comp-private#251 (SALE-49 evidence automation scheduler)

🤖 Generated with Claude Code


Summary by cubic

Restore a single-file Prisma schema for @trycompai/db by building dist/schema.prisma from the v7 multi-file sources. This fixes broken db:getschema scripts for external consumers and unblocks comp-private CI (SALE-49).

  • Bug Fixes
    • Added scripts/build-dist-schema.js to concatenate prisma/schema/*.prisma into dist/schema.prisma (base schema first, others sorted) matching the v2.0.0 format.
    • Hooked into build so the file is published; prisma validate passes and comp-private db:getschema runs succeed.

Written for commit 602aad7. Summary will update on new commits.

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>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
app Building Building Preview, Comment Apr 25, 2026 4:47pm
comp-framework-editor Building Building Preview, Comment Apr 25, 2026 4:47pm
portal Building Building Preview, Comment Apr 25, 2026 4:47pm

Request Review

@Marfuen Marfuen merged commit a27bc43 into main Apr 25, 2026
7 of 10 checks passed
@Marfuen Marfuen deleted the mariano/fix-db-dist-schema branch April 25, 2026 16:48
@claudfuen
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 3.34.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants