Skip to content

Commit fd01a7a

Browse files
committed
Fix backwards compatibility github actions
`bundle exec rake db:parallel:migrate` (which is also used in the backwards compatibility tests) failed since introducing new migration logging (6d2f0fa). The error was `DB_CONNECTION_STRING not set`. This is because when using parallel test execution `POSTGRES_CONNECTION_PREFIX` is used. `DB_CONNECTION_STRING` is set after `DbConfig.new` was called. So the new logging setup has been moved after this command.
1 parent a655a6f commit fd01a7a

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

lib/tasks/db.rake

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,26 +242,32 @@ namespace :db do
242242
end
243243

244244
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
247247
begin
248248
require_relative '../../spec/support/bootstrap/db_config'
249249
DbConfig.new
250250
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.
252252
end
253+
254+
logging_output
255+
db_logger = Steno.logger('cc.db.migrations')
253256
DBMigrator.from_config(RakeConfig.config, db_logger).apply_migrations
254257
end
255258

256259
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
259262
begin
260263
require_relative '../../spec/support/bootstrap/db_config'
261264
DbConfig.new
262265
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.
264267
end
268+
269+
logging_output
270+
db_logger = Steno.logger('cc.db.migrations')
265271
DBMigrator.from_config(RakeConfig.config, db_logger).rollback(number_to_rollback)
266272
end
267273

0 commit comments

Comments
 (0)