File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { loadEnvConfig } from '@next/env';
22import * as fs from 'fs/promises' ;
33import * as path from 'path' ;
44import pg from 'pg' ;
5+ import { DatabaseError } from 'pg-protocol' ;
56
67const projectDir = process . cwd ( ) ;
78loadEnvConfig ( projectDir ) ;
@@ -62,11 +63,11 @@ export default async function globalSetup() {
6263 const sql = await fs . readFile ( filePath , 'utf-8' ) ;
6364 await testPool . query ( sql ) ;
6465 } catch ( e : unknown ) {
65- const pgError = e as { code ?: string } ;
6666 // 42P07 = duplicate_table, 42710 = duplicate_object — schema already applied
67- if ( pgError . code !== '42P07' && pgError . code !== '42710' ) {
68- console . warn ( `Warning: failed to apply ${ file } :` , e ) ;
67+ if ( e instanceof DatabaseError && ( e . code === '42P07' || e . code === '42710' ) ) {
68+ continue ;
6969 }
70+ console . warn ( `Warning: failed to apply ${ file } :` , e ) ;
7071 }
7172 }
7273 } finally {
You can’t perform that action at this time.
0 commit comments