module ActiveRecord::Tasks::DatabaseTasks

Public Instance Methods

create(*arguments) click to toggle source
# File lib/multi_db/active_record_patches.rb, line 102
def create(*arguments)
  create_or_drop(:create, arguments)
end
Also aliased as: create_without_multidb
create_or_drop(*arguments) click to toggle source
# File lib/multi_db/active_record_patches.rb, line 111
def create_or_drop(*arguments)
  create_or_drop = arguments[0]
  arguments = arguments[1]
  
  _config = arguments.shift
  config_name = ActiveRecord::Base.configurations.invert[_config]
  is_test = (config_name == 'test')
  config = _config.dup
  
  case ENV['RAILS_ORG']
  when nil
    # set default org database
    raise "No database name specified in configuration \"#{config_name}\"" unless config['database']
    config['database'] += '_org1'
  when 'sessions'
    # do nothing
  when 'master'
    config = ActiveRecord::Base.master_configuration(is_test ? 'test' : nil)
  else
    config['database'] += '_' + ENV['RAILS_ORG']
  end
  
  arguments.unshift config
  
  case create_or_drop
    when :create then create_without_multidb(*arguments)
    when :drop then drop_without_multidb(*arguments)
  end
end
create_without_multidb(*arguments)
Alias for: create
drop(*arguments) click to toggle source
# File lib/multi_db/active_record_patches.rb, line 107
def drop(*arguments)
  create_or_drop(:drop, arguments)
end
Also aliased as: drop_without_multidb
drop_without_multidb(*arguments)
Alias for: drop