Include `@@index` and `@map` information in `getDMMF`
See original GitHub issueProblem
Given schema
model UserEmailHistory {
id Int @id @default(autoincrement())
user_alias String @map("alias")
send_count Int
historyable_id Int?
historyable_type String?
user_id Int
created_at DateTime?
updated_at DateTime? @updatedAt
@@index([user_id], name: "user_email_history_user_id_foreign")
@@map("user_email_history")
}
using getDMMF will dump as
{
"name": "UserEmailHistory",
"isEmbedded": false,
"dbName": "user_email_history",
"fields": [
{
"name": "id",
"kind": "scalar",
"isList": false,
"isRequired": true,
"isUnique": false,
"isId": true,
"isReadOnly": false,
"type": "Int",
"hasDefaultValue": true,
"default": {
"name": "autoincrement",
"args": []
},
"isGenerated": false,
"isUpdatedAt": false
},
{
"name": "user_alias",
"kind": "scalar",
"isList": false,
"isRequired": true,
"isUnique": false,
"isId": false,
"isReadOnly": false,
"type": "String",
"hasDefaultValue": false,
"isGenerated": false,
"isUpdatedAt": false
},
{
"name": "send_count",
"kind": "scalar",
"isList": false,
"isRequired": true,
"isUnique": false,
"isId": false,
"isReadOnly": false,
"type": "Int",
"hasDefaultValue": false,
"isGenerated": false,
"isUpdatedAt": false
},
{
"name": "historyable_id",
"kind": "scalar",
"isList": false,
"isRequired": false,
"isUnique": false,
"isId": false,
"isReadOnly": false,
"type": "Int",
"hasDefaultValue": false,
"isGenerated": false,
"isUpdatedAt": false
},
{
"name": "historyable_type",
"kind": "scalar",
"isList": false,
"isRequired": false,
"isUnique": false,
"isId": false,
"isReadOnly": false,
"type": "String",
"hasDefaultValue": false,
"isGenerated": false,
"isUpdatedAt": false
},
{
"name": "user_id",
"kind": "scalar",
"isList": false,
"isRequired": true,
"isUnique": false,
"isId": false,
"isReadOnly": false,
"type": "Int",
"hasDefaultValue": false,
"isGenerated": false,
"isUpdatedAt": false
},
{
"name": "created_at",
"kind": "scalar",
"isList": false,
"isRequired": false,
"isUnique": false,
"isId": false,
"isReadOnly": false,
"type": "DateTime",
"hasDefaultValue": false,
"isGenerated": false,
"isUpdatedAt": false
},
{
"name": "updated_at",
"kind": "scalar",
"isList": false,
"isRequired": false,
"isUnique": false,
"isId": false,
"isReadOnly": false,
"type": "DateTime",
"hasDefaultValue": false,
"isGenerated": false,
"isUpdatedAt": true
}
],
"isGenerated": false,
"idFields": [],
"uniqueFields": [],
"uniqueIndexes": []
}
the @@index and @map information are both missing, this make printing dmmf back to schema impossible.
Suggested solution
Return indexes in Model field just like uniqueFields and uniqueIndexes.
add colName or fieldName to show the original db columnName just like dbName.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:9 (2 by maintainers)
Top Results From Across the Web
How to configure indexes in Prisma - LogRocket Blog
Here, we explore what Prisma is, what database indexes are, their importance to database operations, and how to configure them.
Read more >Trouble using "Integer" type in Prisma ORM schema for ...
npx prisma generate Environment variables loaded from .env Prisma schema loaded from prisma/schema.prisma Error: Get DMMF: Schema parsing ...
Read more >prisma-schema-transformer - npm
This project utilizes the getDMMF method from @prisma/sdk to perform some post-processing work on generated Prisma schema, including the ...
Read more >ScalaSTM — Indexed Map
View , which are STM-integrated concurrent maps. ... Note that we're careful to add all of the existing elements of the map to...
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

We also need
@mapinformation on fields quite desperately! See my usecase https://github.com/prisma/prisma/issues/14087Shouldn’t be a difficult things to fix, right? And would open so many possibilities for better tooling. 🙏
For the time being I had to jump through terrible hoops doing prisma.schema pre-processing and extracting all the needed attributes (
@mapand@db.ObjectId) into the field’s documentation, and accessing it via DMMF from there.But yeah, would be actually great to see all Prisma schema attributes accessible in DMMF.