drizzle-seed: how to avoid duplicate key value violates unique constraint for composite keys?

I have a usersWorkspaces table which references users and workspaces. When I run the seed script (I haven't defined any behavior for userWorkspaces), I'm getting the following error:
PostgresError: duplicate key value violates unique constraint "user_workspaces_user_id_workspace_id_pk"
severity_local: 'ERROR',
severity: 'ERROR',
code: '23505',
detail: 'Key (user_id, workspace_id)=(d082bd94-0b99-4e48-528d-3d4217c3e50f, 1c40f298-7c31-4fde-0efb-7ce7cbdbd2af) already exists.',
schema_name: 'public',
table_name: 'user_workspaces',
constraint_name: 'user_workspaces_user_id_workspace_id_pk',
file: 'nbtinsert.c',
line: '664',
routine: '_bt_check_unique'
}
PostgresError: duplicate key value violates unique constraint "user_workspaces_user_id_workspace_id_pk"
severity_local: 'ERROR',
severity: 'ERROR',
code: '23505',
detail: 'Key (user_id, workspace_id)=(d082bd94-0b99-4e48-528d-3d4217c3e50f, 1c40f298-7c31-4fde-0efb-7ce7cbdbd2af) already exists.',
schema_name: 'public',
table_name: 'user_workspaces',
constraint_name: 'user_workspaces_user_id_workspace_id_pk',
file: 'nbtinsert.c',
line: '664',
routine: '_bt_check_unique'
}
It seems the seed script is trying to create duplicate entries violating the composite key. I saw that currently drizzle-seed doesn't support the third parameter in Drizzle tables, which I suppose includes the composite primary key. What's a good way to go around this?
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?