Sha256: 3e86d8aec1072007ecbe875aee58d1a5518d4a8400583bcbe871c2e19bf155a2

Contents?: true

Size: 590 Bytes

Versions: 1

Compression:

Stored size: 590 Bytes

Contents

module SearchCraft::DumpSchema
  extend ActiveSupport::Concern

  # If in Rails, dump schema.rb after rebuilding views
  def dump_schema!
    return unless Rails.env.development?
    require "active_record/tasks/database_tasks"

    env = Rails.env
    db_configs = ActiveRecord::Base.configurations.configs_for(env_name: env)
    db_configs.each do |db_config|
      ActiveRecord::Tasks::DatabaseTasks.dump_schema(db_config, ActiveRecord.schema_format)
    end
  rescue ActiveRecord::NoDatabaseError
  rescue => e
    warn "Error dumping schema: #{e.message}"
    pp e.backtrace
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
searchcraft-0.4.0 lib/searchcraft/dump_schema.rb