Existing Database in snake_case
I'm running db pull on an existing database.... they are come in as snake_case. Anyway to auto convert these?
1 Reply
You've gone full bot mode! Let me fetch that AI answer for you ASAP.
Based on the knowledge sources provided, there is currently no built-in automatic way to convert snake_case table and column names to camelCase or PascalCase when running
prisma db pull
on an existing database. However, there are a few workarounds and potential solutions:
1. Manual Mapping: You can manually add @map
and @@map
attributes to your Prisma schema to map the snake_case database names to camelCase or PascalCase names in your Prisma Client API. This is described in the Prisma documentation.
2. Third-party Tools: There are some community-created tools that can help automate this process:
- prisma-case-format
- prisma-schema-transformer
These tools can be used to automatically transform snake_case to camelCase in your Prisma schema.
3. Feature Request: There is an open feature request on GitHub for Prisma to support global configuration for name casing. You can follow the progress of this issue: Support global config for name casing (table, fields).
While these solutions can help, it's important to note that automatic conversion is not currently a built-in feature of Prisma. The Prisma team is aware of this need and is collecting input on how to implement it in the future.
For now, you'll need to either manually adjust your schema or use one of the third-party tools mentioned above to achieve the desired naming convention in your Prisma Client API.