Wire up prisma-dbml-generator so schema.dbml regenerates on prisma:generate - #935
Open
iamtanuj18 wants to merge 3 commits into
Open
Wire up prisma-dbml-generator so schema.dbml regenerates on prisma:generate#935iamtanuj18 wants to merge 3 commits into
iamtanuj18 wants to merge 3 commits into
Conversation
2 tasks
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.
Fixes #933.
Wires up
prisma-dbml-generatoras a Prisma generator soapplication/backend/prisma/dbml/schema.dbmlregenerates automatically on everyyarn workspace backend prisma:generate. The DBML file is committed to git alongsideschema.prismaso its diff surfaces on schema-touching PRs and reviewers see the structural change alongside the code change.For the interactive visual, the DBML content pastes into a dbdiagram.io project at https://dbdiagram.io/d/CTRL-ERD-6a7554fa35ee2e87b04f19e0 which renders it with clickable relationships, hover tooltips for encryption metadata (
@encrypted,@encryption:hash(x)), and pan/zoom. The interactive URL isn't auto-synced from the repo. Someone has to paste the fresh DBML in whenever the schema changes.What's added
prisma-dbml-generatoras a dev dep in the backend workspacegenerator dbml { ... }block inschema.prismaconfigured for CTRL, PostgreSQL, and to include relation fields (needed so FK columns render)application/backend/prisma/dbml/schema.dbml(auto-generated, 267 lines, matches the current schema including all@encryptedand@encryption:hash(x)notes)prisma:erd:checkscript chained after everyprisma:generate. Usesgit diff --exit-codeon the committed DBML to detect drift and prints a warning nudging whoever ran it to paste the new content into the dbdiagram.io project.Known limitations
Manual sync to dbdiagram.io.
prisma-dbml-generatorproduces DBML text only, not SVG or any interactive rendering. dbdiagram.io doesn't expose an API for programmatic diagram updates on any tier, so keeping the interactive view current requires someone to paste the fresh DBML in. Theprisma:erd:checkwarning nudges devs when they runprisma:generatelocally, but the paste step itself is manual.Single editor on dbdiagram.io free tier. The CTRL project sits on my personal account so only I can update the pasted DBML. Worth migrating to a shared/team-owned account later within free tier perhaps.
Manual
npx prisma generatebypasses the check. All standard yarn workflows fire the drift check —yarn prisma:generate,yarn build,yarn prisma:migrate(andmake seedsince it calls migrate). The only path that skips is someone typingnpx prisma generateorprisma generatedirectly.