Error: There is not enough information to infer relation
Hey,
I'm trying to convert a Prisma schema to Drizzle.
Here's the schema:
When I try to run
drizzle-kit studio
I get this error: "rror: There is not enough information to infer relation "public.messages.replies"
at normalizeRelation"
Am I doing something wrong here?19 Replies
Here's the relation code:
You need to define all the relations from both "sides"
Wow, that was fast haha In this case, what would be the other "side"? Since it's all "messages" (i.e replies also refers to messages)
If there is more than one relation between two tables, you need to give them unique names
On both "sides"
Like this?
Yeah
The thing is that here, it's all related to the same table, the Message table.
This is what I'm using and I'm still seeing the error when starting the Drizzle Studio:
That might help you
Oh, I see you're trying to make it all the same table
Thank you for sending this @nk! But my case here is that I'm declaring the relations of the table "A", and I stablish 2 relations to itselft
Yeah, that's the problem!
The problem with doing it that way is that it makes it where you can easily have a "child" message with a null ID
It's probably just easier to make it 2 tables
Cause you won't be able to create a message without a parent if you put notNull on the parent ID
I wrote an example for this a while ago
Let me see
https://discord.com/channels/1043890932593987624/1111572543556550738
GitHub
[FEATURE]: Customizable many relations · Issue #674 · drizzle-team/...
Describe want to want Relation support is cool. The fact that it only uses 1 single query is even better. However, right now, it's pretty limited in scope and the rules for how many is composed...
Yeah
It's a bit different, you're going from users > follows & follows and follows > users & users.
In my case: I'm going from messages > messages & messages
Maybe what @nk suggested is a way to do this, but ideallly I wouldn't need to change the current schema, which is something like this:
(And please correct me if I'm wrong, maybe I'm missing something)
I figured it out
Or let me test it first