Prevent creation of the Docker containers if just running a db rake task

Otherwise, the rake task might fail if the database connection could not be established (e.g. when creating a new database).
This commit is contained in:
Sebastian Serth
2018-11-22 19:02:33 +01:00
parent 0fbbe97ae4
commit 942d87f9ba

View File

@ -1,6 +1,8 @@
DockerClient.initialize_environment unless Rails.env.test? && `which docker`.blank?
if ApplicationRecord.connection.tables.present? && DockerContainerPool.config[:active]
if !Rake.application.top_level_tasks.to_s.include?('db:') &&
ApplicationRecord.connection.tables.present? &&
DockerContainerPool.config[:active]
DockerContainerPool.start_refill_task
at_exit { DockerContainerPool.clean_up }
end