Magic introspection naming
timsuchanek opened this issue · comments
If you introspect a TypeORM or Sequelize (or most other ORMs) schema, you more often than not end up with a schema like so:
model users {
id Int @id
}
model posts {
id Int @id
userId users
}
The entities in TypeORM are called User
and Post
, so for a user coming from these libraries, the naming now is not what they are used to and also goes against the default conventions we have with Prisma.
Optimally we would instead perform heuristics that introduce a couple of @map
's that transform the schema like so:
model User {
id Int @id
@@map("users")
}
model Post {
id Int @id
user User @map("userId")
@@map("posts")
}
We should take into account the naming conventions of various popular frameworks (non-exhaustive):
- Django
- Active Record
- Sequelize
- TypeORM
Related (or pretty much duplicate of: https://github.com/prisma/prisma2/issues/1325)