@@ -97,7 +97,10 @@ export async function runMigration(
97
97
const error = coerceError ( rawError ) ;
98
98
await event . client . query ( "rollback" ) ;
99
99
await hooks . process ( "migrationError" , { ...event , error } ) ;
100
- if ( ! migrationInsertComplete && error . code === "23505" ) {
100
+ if (
101
+ ! migrationInsertComplete &&
102
+ CLASH_CODES . includes ( error . code as string )
103
+ ) {
101
104
// Someone else did this migration! Success!
102
105
logger . debug (
103
106
`Some other worker has performed migration ${ migrationFile } ; continuing.` ,
@@ -146,13 +149,13 @@ select current_setting('server_version_num') as server_version_num,
146
149
break ;
147
150
} catch ( rawE ) {
148
151
const e = coerceError ( rawE ) ;
149
- if ( attempts === 0 && ( e . code === "42P01" || e . code === "42703" ) ) {
152
+ if ( attempts === 0 && NX_CODES . includes ( e . code as string ) ) {
150
153
try {
151
154
await installSchema ( compiledSharedOptions , event ) ;
152
155
break ;
153
156
} catch ( rawE2 ) {
154
157
const e2 = coerceError ( rawE2 ) ;
155
- if ( e2 . code === "23505" ) {
158
+ if ( CLASH_CODES . includes ( e2 . code as string ) ) {
156
159
// Another instance installed this concurrently? Go around again.
157
160
} else {
158
161
throw e2 ;
@@ -208,3 +211,8 @@ select current_setting('server_version_num') as server_version_num,
208
211
await hooks . process ( "postmigrate" , event ) ;
209
212
} ) ;
210
213
}
214
+
215
+ /** Doesn't exist */
216
+ const NX_CODES = [ "42P01" , "42703" ] ;
217
+ /** Someone else created */
218
+ const CLASH_CODES = [ "23505" , "42P06" , "42P07" , "42710" ] ;
0 commit comments