application/backend/prisma/schema.prisma is the source of truth for CTRL's data model.
suggestion: wire up prisma-dbml-generator so every prisma generate run produces a fresh schema.dbml locally. The DBML file can itself be gitignored (intermediate artifact). When the schema changes, the developer pastes the fresh DBML into the dbdiagram.io project to keep the shared interactive ERD in sync, then exports the rendered SVG from dbdiagram.io and commits that into the ctrl-docs repo.
four tools were evaluated before going ahead with DBML — yamltools.dev, vanilla prisma-erd-generator, a forked version of it, and prisma-dbml-generator. Only the DBML path hits full accuracy for CTRL's schema features (@encrypted fields, @encryption:hash(x) markers, cascade rules, compound uniques, composite PKs) once rendered through dbdiagram.io.
Suggested implementation:
yarn workspace backend add -D prisma-dbml-generator
- Add
generator dbml { provider = "prisma-dbml-generator", output = "./dbml", outputName = "schema.dbml", projectName = "CTRL", projectDatabaseType = "PostgreSQL", includeRelationFields = "true" } to schema.prisma
- Add
application/backend/prisma/dbml/ to .gitignore so the generated DBML stays local
- Run
yarn workspace backend prisma generate once to produce the initial schema.dbml
- Create a dbdiagram.io project (free tier), paste the DBML content in, save, and grab the shareable URL for the interactive view
- Export the rendered ERD as SVG from dbdiagram.io and commit it into the ctrl-docs repo
References:
application/backend/prisma/schema.prismais the source of truth for CTRL's data model.suggestion: wire up
prisma-dbml-generatorso everyprisma generaterun produces a freshschema.dbmllocally. The DBML file can itself be gitignored (intermediate artifact). When the schema changes, the developer pastes the fresh DBML into the dbdiagram.io project to keep the shared interactive ERD in sync, then exports the rendered SVG from dbdiagram.io and commits that into the ctrl-docs repo.four tools were evaluated before going ahead with DBML — yamltools.dev, vanilla
prisma-erd-generator, a forked version of it, andprisma-dbml-generator. Only the DBML path hits full accuracy for CTRL's schema features (@encryptedfields,@encryption:hash(x)markers, cascade rules, compound uniques, composite PKs) once rendered through dbdiagram.io.Suggested implementation:
yarn workspace backend add -D prisma-dbml-generatorgenerator dbml { provider = "prisma-dbml-generator", output = "./dbml", outputName = "schema.dbml", projectName = "CTRL", projectDatabaseType = "PostgreSQL", includeRelationFields = "true" }toschema.prismaapplication/backend/prisma/dbml/to.gitignoreso the generated DBML stays localyarn workspace backend prisma generateonce to produce the initialschema.dbmlReferences: