@@ -48,8 +48,14 @@ def dump_database
4848 # 3. restore teh db from file
4949 # 4. verify the study count (permissions are not granted again to prevent bad data from being used)
5050 # 5. grant connection permissions again
51- def restore_database ( schema_type , connection , filename )
52- schema = 'ctgov'
51+ def restore_database ( schema , connection , filename )
52+ if schema =~ /beta/
53+ schema = 'ctgov_beta'
54+ elsif schema =~ /archive/
55+ schema = 'ctgov_archive'
56+ else
57+ schema = 'ctgov'
58+ end
5359 config = connection . instance_variable_get ( '@config' )
5460 host , port , username , database , password = config [ :host ] , config [ :port ] , config [ :username ] , config [ :database ] , config [ :password ]
5561
@@ -209,7 +215,7 @@ def add_constraints
209215 migration . add_foreign_key child_table , parent_table , column : child_column , primary_key : parent_column , name : "#{ child_table } _#{ child_column } _fkey"
210216 rescue => e
211217 log ( e )
212- event . add_problem ( "#{ Time . zone . now } : #{ e } " )
218+ event . add_problem ( "#{ Time . zone . now } : #{ e } " ) if event
213219 end
214220 }
215221 end
@@ -221,15 +227,15 @@ def remove_indexes_and_constraints
221227 con . remove_foreign_key table_name , column : :nct_id if con . foreign_keys ( table_name ) . map ( &:column ) . include? ( "nct_id" )
222228 rescue => e
223229 log ( e )
224- event . add_problem ( "#{ Time . zone . now } : #{ e } " )
230+ event . add_problem ( "#{ Time . zone . now } : #{ e } " ) if event
225231 end
226232
227233 con . indexes ( table_name ) . each { |index |
228234 begin
229235 migration . remove_index ( index . table , index . columns ) if !should_keep_index? ( index ) and migration . index_exists? ( index . table , index . columns )
230236 rescue => e
231237 log ( e )
232- event . add_problem ( "#{ Time . zone . now } : #{ e } " )
238+ event . add_problem ( "#{ Time . zone . now } : #{ e } " ) if event
233239 end
234240 }
235241 }
@@ -241,7 +247,7 @@ def remove_indexes_and_constraints
241247 con . remove_foreign_key table , column : column if con . foreign_keys ( table ) . map ( &:column ) . include? ( column )
242248 rescue => e
243249 log ( e )
244- event . add_problem ( "#{ Time . zone . now } : #{ e } " )
250+ event . add_problem ( "#{ Time . zone . now } : #{ e } " ) if event
245251 end
246252 }
247253 end
@@ -253,7 +259,7 @@ def remove_constrains
253259 con . remove_foreign_key table_name , column : :nct_id if con . foreign_keys ( table_name ) . map ( &:column ) . include? ( "nct_id" )
254260 rescue => e
255261 log ( e )
256- event . add_problem ( "#{ Time . zone . now } : #{ e } " )
262+ event . add_problem ( "#{ Time . zone . now } : #{ e } " ) if event
257263 end
258264 }
259265
@@ -264,7 +270,7 @@ def remove_constrains
264270 con . remove_foreign_key table , column : column if con . foreign_keys ( table ) . map ( &:column ) . include? ( column )
265271 rescue => e
266272 log ( e )
267- event . add_problem ( "#{ Time . zone . now } : #{ e } " )
273+ event . add_problem ( "#{ Time . zone . now } : #{ e } " ) if event
268274 end
269275 }
270276 end
@@ -284,6 +290,7 @@ def self.loadable_tables
284290 study_json_records
285291 use_cases
286292 use_case_attachments
293+ verifiers
287294 )
288295 table_names = con . tables . reject { |table |blacklist . include? ( table ) }
289296 end
0 commit comments