File tree 1 file changed +15
-2
lines changed
1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ const importGtfsAtomically = async (cfg) => {
41
41
tmpDir,
42
42
gtfstidyBeforeImport,
43
43
determineDbsToRetain,
44
+ continueOnFailureDeletingOldDb,
44
45
gtfsPostprocessingDPath,
45
46
} = {
46
47
logger : console ,
@@ -64,6 +65,7 @@ const importGtfsAtomically = async (cfg) => {
64
65
? [ prevImport , ...latestTwo . slice ( - 1 ) ]
65
66
: latestTwo
66
67
} ,
68
+ continueOnFailureDeletingOldDb : process . env . GTFS_IMPORTED_CONTINUE_ON_FAILURE_DELETING_OLD_DB === 'true' ,
67
69
gtfsPostprocessingDPath : null ,
68
70
...cfg ,
69
71
}
@@ -164,8 +166,19 @@ const importGtfsAtomically = async (cfg) => {
164
166
}
165
167
logger . info ( `dropping database "${ oldDb . name } " containing an older or unfinished import` )
166
168
// todo: `WITH (FORCE)`? – https://stackoverflow.com/a/68982312/1072129
167
- await dbMngmtClient . query ( pgFormat ( 'DROP DATABASE %I' , oldDb . name ) )
168
- result . deletedDatabases . push ( oldDb )
169
+ try {
170
+ await dbMngmtClient . query ( pgFormat ( 'DROP DATABASE %I' , oldDb . name ) )
171
+ result . deletedDatabases . push ( oldDb )
172
+ } catch ( err ) {
173
+ if ( continueOnFailureDeletingOldDb ) {
174
+ logger . warn ( {
175
+ error : err ,
176
+ dbName : oldDb . name ,
177
+ } , `failed to delete old database "${ oldDb . name } "` )
178
+ } else {
179
+ throw err
180
+ }
181
+ }
169
182
}
170
183
}
171
184
You can’t perform that action at this time.
0 commit comments