Skip to content
This repository
tree: d29727235a
Fetching contributors…

Cannot retrieve contributors at this time

file 19 lines (17 sloc) 0.628 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
class ActiveRecord::Tasks::DatabaseTasks
  TASKS_PATTERNS = {
    /mysql/ => ActiveRecord::Tasks::MySQLDatabaseTasks,
    # /postgresql/ => ActiveRecord::Tasks::PostgreSQLTasker,
    /sqlite/ => ActiveRecord::Tasks::SQLiteDatabaseTasks
  }

  def self.create(configuration)
    class_for_adapter(configuration['adapter']).new(configuration).create
  rescue Exception => e
    $stderr.puts e, *(e.backtrace)
    $stderr.puts "Couldn't create database for #{configuration.inspect}"
  end

  def self.class_for_adapter(adapter)
    key = TASKS_PATTERNS.keys.detect { |key| adapter[key] }
    TASKS_PATTERNS[key]
  end
end
Something went wrong with that request. Please try again.