diff --git a/lib/gouda/railtie.rb b/lib/gouda/railtie.rb index 2a41584..08c4979 100644 --- a/lib/gouda/railtie.rb +++ b/lib/gouda/railtie.rb @@ -2,6 +2,8 @@ module Gouda class Railtie < Rails::Railtie + UNINITIALISED_DATABASE_EXCEPTIONS = [PG::UndefinedTable, ActiveRecord::NoDatabaseError, ActiveRecord::StatementInvalid, ActiveRecord::ConnectionNotEstablished] + rake_tasks do task preload: :setup do if defined?(Rails) && Rails.respond_to?(:application) @@ -54,7 +56,7 @@ class Railtie < Rails::Railtie Gouda::Scheduler.build_scheduler_entries_list! begin Gouda::Scheduler.upsert_workloads_from_entries_list! - rescue PG::UndefinedTable, ActiveRecord::NoDatabaseError + rescue *UNINITIALISED_DATABASE_EXCEPTIONS # Do nothing. On a freshly checked-out Rails app, running even unrelated Rails tasks # (such as asset compilation) - or, more importantly, initial db:create - # will cause a NoDatabaseError, as this is a chicken-and-egg problem. That error