Drizzle TeamDT
Drizzle Team11mo ago
nu

How to handle multiple unique constraints with onConflictDoUpdate?

My postgres table has 2 unique constraints:
    unique("unique_game").on(table.idTeamHome, table.idTeamAway, table.time),
    unique("unique_id").on(table.idEvent),


During insert I am able to handle unique_id constraint, but how do I handle the other one?

    .onConflictDoUpdate({
      target: games.idEvent,
      set: {
        time: sql.raw(`excluded."${games.time.name}"`),
        idEvent: sql.raw(`excluded."${games.idEvent.name}"`),
      },
Was this page helpful?