Sha256: 4a6c7abace3f2bf3c44e89b27a929b242515eb2c86124729962554de37fe717c

Contents?: true

Size: 513 Bytes

Versions: 2

Compression:

Stored size: 513 Bytes

Contents

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

  def self.call
    new.call
  end

  def call
    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

2 entries across 2 versions & 1 rubygems

Version Path
combustion-0.6.0 lib/combustion/database/load_schema.rb
combustion-0.5.5 lib/combustion/database/load_schema.rb