© 2026 Hedgehog Software, LLC

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

Composite primary key, multiple primary keys

I am following the
Lucia-auth
Lucia-auth
docs for multiple oauth providers, it's says:
PRIMARY KEY (provider_id, provider_user_id)
PRIMARY KEY (provider_id, provider_user_id)
as shown here:
https://lucia-auth.com/guides/oauth/multiple-providers

I am using Postgres with TypeScript so I made it like this, instead of the SQLite example they use.
export const oauthAccount = pgTable(
  'oath_account',
  {
    provider_id: text('provider_id').notNull(),
    provider_user_id: text('provider_user_id').notNull(),
    user_id: text('user_id')
      .notNull()
      .references(() => users.id),
  },
  (table) => {
    return {
      pk: primaryKey({
        columns: [table.provider_id, table.provider_user_id],
      }),
    };
  }
);
export const oauthAccount = pgTable(
  'oath_account',
  {
    provider_id: text('provider_id').notNull(),
    provider_user_id: text('provider_user_id').notNull(),
    user_id: text('user_id')
      .notNull()
      .references(() => users.id),
  },
  (table) => {
    return {
      pk: primaryKey({
        columns: [table.provider_id, table.provider_user_id],
      }),
    };
  }
);


Its returning in the terminal:
multiple primary keys for table "oath_account" are not allowed
multiple primary keys for table "oath_account" are not allowed
.. But in the docs it shows I need it, right, what am I doing wrong?

Thanks in advance.
Lucia
Multiple OAuth providers
Lucia is an open source auth library that abstracts away the complexity of handling sessions.
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

Composite Primary Key from Foreign Keys
Drizzle TeamDTDrizzle Team / help
3y ago
Composite Primary Key?
Drizzle TeamDTDrizzle Team / help
16mo ago
reference composite primary key
Drizzle TeamDTDrizzle Team / help
3y ago
Compostie primary key of a composite primary key
Drizzle TeamDTDrizzle Team / help
2y ago