Why are the db config and generators mixed with the schema definition?
See original GitHub issueI’m curious if there’s a reason behind this:
generator photon {
provider = "photonjs"
}
generator nexus_prisma {
provider = "nexus-prisma"
}
datasource db {
provider = "sqlite"
url = "file:dev.db"
}
being inside the schema.prisma
file. I think it makes more sense if it’s in a separate file.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Add commands for adding generator or datasource to prisma ...
Add commands for adding generator or datasource to prisma schema #375 ... Why are the db config and generators mixed with the schema...
Read more >Database Schema Structure - DbSchema
Databases store data based on the schema definition, so understanding it is a key part of designing databases. In this chapter, we will...
Read more >mix phx.gen.schema — Phoenix v1.6.15 - HexDocs
Settings View Source mix phx.gen.schema (Phoenix v1.6.15) ... Generates an Ecto schema and migration. ... The first argument is the schema module followed...
Read more >Documentation for the mysql-schema Generator
Generates a MySQL schema based on the model or schema defined in the OpenAPI specification (v2, v3). #CONFIG OPTIONS. These options may be ......
Read more >Schema Code Generation - Scala's SLICK
The Slick code generator is a convenient tool for working with an existing or evolving database schema. It can be run stand-alone or...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@matthewmueller: I think separating out and being able to import
.prisma
files solves this problem but I thought I would document the use case below:I would like to be able to separate out
datasource
from the schema. We often want to have the same app running on several databases (production, staging, testing, QA, dev) and being able to swap databases, while keeping the same schema would be valuable. Currently, I can do this by making each field anenv
variable and having separate.env
fields but that’s pretty tedious. Hope you implement importing of.prisma
files soon!See also https://github.com/prisma/prisma2/issues/375 and https://github.com/prisma/prisma2/issues/150.
@kitze Hey! I was the one that pushed for Prisma having a single syntax that supports both configuration and schema definitions in a single file. Prisma’s syntax is inspired by HCL (Terraform’s language). We like how HCL is able to nicely model relationships in text.
Additionally, we came to the conclusion that both the database configuration and the schema definition are just application configuration. The schema definition is actually just “configuration for your database”.
That being said, we anticipate that many people will prefer to separate this configuration from the schema. In the past, we used YAML for configuration and GraphQL’s SDL syntax for the schema definition. This made the separation mandatory. We wanted to make this separation optional.
It’s not implemented yet, but soon you’ll be able to import
.prisma
files. Here’s a spec for how that will look: https://github.com/prisma/specs/tree/master/schema#importing-schemas