class Combustion::Database::LoadSchema

Constants

UnknownSchemaFormat

Public Class Methods

call() click to toggle source
# File lib/combustion/database/load_schema.rb, line 6
def self.call
  new.call
end

Public Instance Methods

call() click to toggle source
# File lib/combustion/database/load_schema.rb, line 10
def call
  ActiveRecord::Schema.verbose = false

  case schema_format
  when :ruby
    load_ruby_schema
  when :sql
    load_sql_schema
  else
    raise UnknownSchemaFormat, "Unknown schema format: #{schema_format}"
  end
end

Private Instance Methods

load_ruby_schema() click to toggle source
# File lib/combustion/database/load_schema.rb, line 25
def load_ruby_schema
  load Rails.root.join("db", "schema.rb")
end
load_sql_schema() click to toggle source
# File lib/combustion/database/load_schema.rb, line 29
def load_sql_schema
  ActiveRecord::Base.connection.execute(
    File.read(Rails.root.join("db", "structure.sql"))
  )
end
schema_format() click to toggle source
# File lib/combustion/database/load_schema.rb, line 35
def schema_format
  Combustion.schema_format
end