Skip to content
This repository was archived by the owner on Mar 7, 2024. It is now read-only.

Commit 0ffbbb7

Browse files
committed
Ignore unique constraint "pg_type_typname_nsp_index" error
1 parent f371532 commit 0ffbbb7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,11 @@ export const setupPlugin: PostgresPlugin['setupPlugin'] = async (meta) => {
101101
config
102102
)
103103

104-
if (queryError) {
104+
// Raise error, but ignore `duplicate key value violates unique constraint "pg_type_typname_nsp_index"`,
105+
// which can occur when multiple plugin server instance run this CREATE TABLE query at the same time.
106+
// `pg_type_typname_nsp_index` marks a race condition in Postgres, but it doesn't make CREATE TABLE IF NOT EXISTS
107+
// any less safe.
108+
if (queryError && !queryError.message.includes('pg_type_typname_nsp_index')) {
105109
throw new Error(`Unable to connect to PostgreSQL instance and create table with error: ${queryError.message}`)
106110
}
107111

0 commit comments

Comments
 (0)