class Qyu::Store::ActiveRecord::Utils

Public Class Methods

ensure_db_ready(db_config) click to toggle source
# File lib/qyu/store/activerecord/utils.rb, line 9
def self.ensure_db_ready(db_config)
  begin
    ::ActiveRecord::Base.establish_connection(db_config).connection
  rescue ::ActiveRecord::NoDatabaseError
    # :nocov:
    Rake::Task['qyu:db:create'].invoke
    # :nocov:
  end

  begin
    Rake::Task['qyu:db:migrate_without_schema_update'].invoke
    # :nocov:
  rescue ::ActiveRecord::ConcurrentMigrationError
    Qyu.logger.info 'Concurrent Qyu database migration running. Skipping...'
    # :nocov:
  end
end