Error: There are multiple relations between "__public__.*" and "*". Please specify relation name
I got this error and originally it was a legitimate error (which i fixed) however drizzle studio is still complaining about it.
3 Replies
@Joe Hey! Can you share your drizzle schema?
export const userRelations = relations(user, ({ many }) => ({
sessions: many(gameSession),
createdDecks: many(deck),
playerStates: many(playerState),
activeGames: many(gameSession, {
relationName: 'activePlayer'
}),
wonGames: many(gameSession, {
relationName: 'winner'
}),
}));
export const gameSessionRelations = relations(gameSession, ({ one, many }) => ({
game: one(game, {
fields: [gameSession.gameId],
references: [game.id],
}),
deck: one(deck, {
fields: [gameSession.deckId],
references: [deck.id],
}),
currentPhase: one(phase, {
fields: [gameSession.currentPhaseId],
references: [phase.id],
}),
activePlayer: one(user, {
fields: [gameSession.activePlayerId],
references: [user.id],
relationName: 'activePlayer'
}),
winner: one(user, {
fields: [gameSession.winnerId],
references: [user.id],
relationName: 'winner'
}),
playerStates: many(playerState),
actions: many(gameAction),
events: many(gameEvent),
}));
Error: There are multiple relations between "public.gameSession" and "user". Please specify relation name
is the relation supposed to reference one side or something different to avoid clash?
It looks like the error is that you added
one
relations for activeGames
and wonGames
but did not add them for sessions
.