module ActiveRecord::ShardFor::DatabaseTasks::TasksForSingleConnection

Create, drop, load_schema for single connection config.

Public Instance Methods

create(connection_name) click to toggle source

@param [String] connection_name

# File lib/activerecord/shard_for/database_tasks.rb, line 157
def create(connection_name)
  configuration = ActiveRecord::Base.configurations[connection_name]
  ActiveRecord::Tasks::DatabaseTasks.create(configuration)
  # Re-configure using configuration with database
  ActiveRecord::Base.establish_connection(configuration)
end
drop(connection_name) click to toggle source

@param [String] connection_name

# File lib/activerecord/shard_for/database_tasks.rb, line 165
def drop(connection_name)
  configuration = ActiveRecord::Base.configurations[connection_name]
  ActiveRecord::Tasks::DatabaseTasks.drop(configuration)
end
load_schema(connection_name) click to toggle source

@param [String] connection_name

# File lib/activerecord/shard_for/database_tasks.rb, line 171
def load_schema(connection_name)
  configuration = ActiveRecord::Base.configurations[connection_name]

  case
  when ar5? || ar6?
    ActiveRecord::Tasks::DatabaseTasks.load_schema(configuration, :ruby)
  when ar42? || ar417_above?
    ActiveRecord::Tasks::DatabaseTasks.load_schema_for(configuration, :ruby)
  when ar41?
    ActiveRecord::Base.establish_connection(configuration)
    ActiveRecord::Tasks::DatabaseTasks.load_schema(:ruby)
  else
    raise "This version of ActiveRecord is not supported: v#{ActiveRecord::VERSION::STRING}"
  end
end