Usage Guide
Once installed and configured in your schema.prisma, the ERD generator integrates seamlessly into your standard Prisma workflow.
Generating Diagrams
Every time you run the standard Prisma generate command, the diagram will be updated:
npx prisma generate
This is particularly useful in development environments where schema changes happen frequently.
Disabling Generation
You might not always want to generate an ERD, especially in production environments or specific CI/CD steps (like Docker builds) to save time and reduce image size (avoiding Puppeteer dependencies).
Via Environment Variable
You can disable the generator dynamically by setting the DISABLE_ERD environment variable:
DISABLE_ERD=true npx prisma generate
Via Configuration
You can also hardcode the disable state in your schema (though environment variables are usually preferred for conditional execution):
generator erd {
provider = "prisma-erd-generator"
disabled = true
}
Via Dockerfile Optimization
If you want to completely remove the generator dependency inside a Docker build to save space, you can use sed to remove the generator block from your schema before generation:
# Deletes lines 5-9 from prisma/schema.prisma (adjust line numbers as needed)
RUN sed -i '5,9d' prisma/schema.prisma
RUN npx prisma generate
Debugging
If the diagram isn't being generated as expected, you can enable debug mode. This will output detailed logs and create intermediate files (like the raw mermaid definition) in a prisma/debug directory.
Via Environment Variable:
ERD_DEBUG=true npx prisma generate
Via Config:
generator erd {
provider = "prisma-erd-generator"
erdDebug = true
}