Make two columns unique (composite primary key)

Hey everyone, I need to make the provider_id and provider_user_id to be unique together (composite primary key). After migration it returns that it is not allowed to have multiple primary keys. But it does seem to be the way Drizzle ORM want it to work, I think. Anyone in here that encountered this before with TypeScript, Drizzle ORM?
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],
}),
};
}
);
Thank you in advance!
1 Reply
DudeBro
DudeBro9mo ago
@Paddy I have a solution if you still need it. Feel free to ping me here.
Want results from more Discord servers?
Add your server