Composite Primary Key from Foreign Keys

export const userItemsHas = pgTable('user_items_has', {
postId: uuid('post_id').references(() => posts.id),
userItemId: serial("user_item_id").references(() => userItems.id),
},(table) => {
return {
pk: primaryKey(table.postId, table.userItemId),
};
});
export const userItemsHas = pgTable('user_items_has', {
postId: uuid('post_id').references(() => posts.id),
userItemId: serial("user_item_id").references(() => userItems.id),
},(table) => {
return {
pk: primaryKey(table.postId, table.userItemId),
};
});
Error: Failed to run sql query: multiple primary keys for table "user_items_has" are not allowed
3 Replies
finn
finnOP2y ago
posts.id and userItems.id are Primary Keys in their respective tables, if that matters
Andrii Sherman
Do you see this error while using orm or kit?
finn
finnOP2y ago
turns it out was just a migration issue (on my end) solved now, thanks
Want results from more Discord servers?
Add your server