disambiguate foreign key relations

Help, I need to understand something:

export const team = mysqlTable(
  "Team",
  {
    id: varchar("id", { length: 191 }).notNull().primaryKey(),
    ownerId: varchar("ownerId", { length: 191 })
      .notNull()
      .references(() => user.id),
  },
  (table) => {
    return {
      ownerIdIdx: index("Team_ownerId_idx").on(table.ownerId),
    };
  },
);

export const user = mysqlTable("User", {
  id: varchar("id", { length: 191 }).notNull().primaryKey(),
  activeTeamId: varchar("activeTeamId", { length: 191 })
    .notNull()
    .references(() => team.id),
});


This is giving me an error on team.id references and user.id references. I need to somehow disambiguate these relations I think but couldnt figure out how to do it. Drizzle has some info about disambiguation here:
https://orm.drizzle.team/docs/rqb#disambiguating-relations
But this is mainly for relations() functions where we dont specify actual fk constraints.
image.png
Was this page helpful?