File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -242,26 +242,32 @@ namespace :db do
242
242
end
243
243
244
244
def migrate
245
- logging_output
246
- db_logger = Steno . logger ( 'cc.db.migrations' )
245
+ # The following block, which loads the test DB config is only needed for running migrations in parallel (only in tests)
246
+ # It sets the `DB_CONNECTION_STRING` env variable from `POSTGRES|MYSQL_CONNECTION_PREFIX` + test_database number
247
247
begin
248
248
require_relative '../../spec/support/bootstrap/db_config'
249
249
DbConfig . new
250
250
rescue LoadError
251
- # Only needed when running tests
251
+ # In production the test DB config is not available nor needed, so we ignore this error.
252
252
end
253
+
254
+ logging_output
255
+ db_logger = Steno . logger ( 'cc.db.migrations' )
253
256
DBMigrator . from_config ( RakeConfig . config , db_logger ) . apply_migrations
254
257
end
255
258
256
259
def rollback ( number_to_rollback )
257
- logging_output
258
- db_logger = Steno . logger ( 'cc.db.migrations' )
260
+ # The following block, which loads the test DB config is only needed for running migrations in parallel (only in tests)
261
+ # It sets the `DB_CONNECTION_STRING` env variable from `POSTGRES|MYSQL_CONNECTION_PREFIX` + test_database number
259
262
begin
260
263
require_relative '../../spec/support/bootstrap/db_config'
261
264
DbConfig . new
262
265
rescue LoadError
263
- # Only needed when running tests
266
+ # In production the test DB config is not available nor needed, so we ignore this error.
264
267
end
268
+
269
+ logging_output
270
+ db_logger = Steno . logger ( 'cc.db.migrations' )
265
271
DBMigrator . from_config ( RakeConfig . config , db_logger ) . rollback ( number_to_rollback )
266
272
end
267
273
You can’t perform that action at this time.
0 commit comments