Sha256: 20d7807912aee9e349260e5bf3caf60fd27c5a1d05643faa1ddc1eb084e3fa36

Contents?: true

Size: 555 Bytes

Versions: 1

Compression:

Stored size: 555 Bytes

Contents

class Combustion::Database::LoadSchema
  UnknownSchemaFormat = Class.new StandardError

  def self.call
    new.call
  end

  def call
    ActiveRecord::Schema.verbose = false

    case schema_format
    when :ruby
      load Rails.root.join('db', 'schema.rb')
    when :sql
      ActiveRecord::Base.connection.execute(
        File.read(Rails.root.join('db', 'structure.sql'))
      )
    else
      raise UnknownSchemaFormat, "Unknown schema format: #{schema_format}"
    end
  end

  private

  def schema_format
    Combustion.schema_format
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
combustion-0.7.0 lib/combustion/database/load_schema.rb