Unable to infer relation

I have the following tables and relations:
export const platforms = pgTable('platforms', {
  id: serial('id').primaryKey(),
  name: text('name').notNull().unique(),
});

export const platformsRelations = relations(platforms, ({ many }) => ({
  founders: many(founders),
}));

export const founders = pgTable('founders', {
  id: serial('id').primaryKey(),
  platformId: integer('platform_id')
    .references(() => platforms.id)
    .notNull(),
  name: text('name').notNull().unique(),
});

My goal is to get a single platform, and all the associated founders with this query:

export const getPlatformData = async (platformName: string) => {
  const platformData = await db.query.platforms.findFirst({
    where: eq(platforms.name, platformName),
    with: {
       founders: true,
    },
  });

  return platformData;
};

But this fails with the error Internal error: Error: There is not enough information to infer relation "platforms.founders" . I'm not exactly sure what I can do to fix this.
Was this page helpful?