© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago•
5 replies
rogueturnip

one-to-many

I might be asking something simple or have to change my model but I thought I'd ask cause I've been stuck for a while.

I have an images table
export const images = pgTable('images', {
  id: text('id')
    .$defaultFn(() => `image_${nanoid()}`)
    .primaryKey(),
  label: text('label'),
  url: text('url'),
  resourceId: text('resource_id'),
  resourceType: text('resource_type'),
  createdAt: timestamp('created_at').defaultNow().notNull(),
});
export const images = pgTable('images', {
  id: text('id')
    .$defaultFn(() => `image_${nanoid()}`)
    .primaryKey(),
  label: text('label'),
  url: text('url'),
  resourceId: text('resource_id'),
  resourceType: text('resource_type'),
  createdAt: timestamp('created_at').defaultNow().notNull(),
});

you can see I have a resourceId and a resourceType because I have different things that can have relations to images. I know I could create a table inbetween but I thought I'd try there, where I'm stuck is on setting up the relation. All the documentation shows
many(images)
many(images)

But when I run it I get an error on the resource I'm doing the with as "There is not enough information to infer the relation"

Any suggestions?
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Help with relations: many-to-many + one-to-one
Drizzle TeamDTDrizzle Team / help
16mo ago
One to Many problem
Drizzle TeamDTDrizzle Team / help
3y ago
one to many query
Drizzle TeamDTDrizzle Team / help
3y ago
Insert One to Many
Drizzle TeamDTDrizzle Team / help
3y ago