Open Jonatthu opened 1 week ago
How do you define it in Prisma? for example, for database push or migration
As long as we can identify which prisma field/type to override, I think this could be done easily. Fyi I have drizzle.custom
in the pipeline to make this much easier. Maybe it could be done like
model A {
/// drizzle.custom {
/// field: { func: "line", imports: [...], opts: { ... } }
/// }
line Int
}
@fdarian Yes allowing some custom fields and imports from comments on prisma to be generated down would be great, but I feel like since this is going to become a common thing it would be better something like:
// @import: import { geometry } from 'drizzle';
model Place {
id String @id @unique @default(dbgenerated("gen_random_uuid()")) @db.Uuid
name String
// @type: geometry('geo', { type: 'point' })
location Unsupported("geometry")?
@@index([location], map: "place_location_idx", type: Gist)
@@schema("public")
}
This is just an example but maybe not the ideal api, I am not sure if you already support this actually. From drizzle docs this is basically what we are trying to achieve to support:
@fdarian any ideas?
https://github.com/drizzle-team/drizzle-orm/releases/tag/0.31.0
Prisma hasn't yet supported geometry officially, but that does not mean we cannot generate from our schema these types using this generator! :D
If somehow this is already supported by default, please let me know how to accomplish such a thing with comments on the prisma file so the generator import the right types for geometry (PostGis) and pg_vector