Sha256: 4f909a1eefc67b1c05e8e10488dfdfd981217515e66f5f1b00f21c1588f0d8ef

Contents?: true

Size: 749 Bytes

Versions: 1

Compression:

Stored size: 749 Bytes

Contents

require 'rake'

load 'qyu/store/activerecord/tasks/db.rake'

module Qyu
  module Store
    module ActiveRecord
      class Utils
        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
            ArcYu.logger.info 'Concurrent Qyu database migration running. Skipping...'
            # :nocov:
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
qyu-store-activerecord-1.0.0 lib/qyu/store/activerecord/utils.rb