class Seed::Configuration

Public Class Methods

new() click to toggle source
# File lib/seed/configuration.rb, line 6
def initialize
  # error if adapter is not mysql
  raise 'seed-snapshot support only MySQL' unless adapter_name == 'Mysql2'
end

Public Instance Methods

adapter_name() click to toggle source
# File lib/seed/configuration.rb, line 11
def adapter_name
  @adapter_name ||= ActiveRecord::Base.connection.adapter_name
end
base_path() click to toggle source

${Rails.root}/tmp/dump

# File lib/seed/configuration.rb, line 24
def base_path
  Pathname.new(Dir.pwd).join('tmp').join('dump')
end
current_version_path() click to toggle source

${Rails.root}/tmp/dump/123456789.sql'

# File lib/seed/configuration.rb, line 29
def current_version_path
  base_path.join(schema_version.to_s + '.sql')
end
database_options() click to toggle source
# File lib/seed/configuration.rb, line 19
def database_options
  @options ||= ActiveRecord::Base.connection.raw_connection.query_options
end
make_tmp_dir() click to toggle source
# File lib/seed/configuration.rb, line 33
def make_tmp_dir
  FileUtils.mkdir_p(base_path) unless File.exist?(base_path)
end
schema_version() click to toggle source
# File lib/seed/configuration.rb, line 15
def schema_version
  @schema_version ||= Digest::SHA1.hexdigest(get_all_versions.sort.join)
end

Private Instance Methods

get_all_versions() click to toggle source
# File lib/seed/configuration.rb, line 39
def get_all_versions
  if ::Gem::Version.new(::ActiveRecord::VERSION::STRING) >= ::Gem::Version.new('5.2')
    migration_paths = ::ActiveRecord::Migrator.migrations_paths
    ::ActiveRecord::MigrationContext.new(migration_paths).get_all_versions
  else
    ::ActiveRecord::Migrator.get_all_versions
  end
end