Module: ActiveRecord::Sharding::DatabaseTasks::TasksForSingleConnection
- Included in:
- ActiveRecord::Sharding::DatabaseTasks
- Defined in:
- lib/active_record/sharding/database_tasks.rb
Instance Method Summary collapse
- #create(connection_name) ⇒ Object
- #drop(connection_name) ⇒ Object
- #execute(connection_name, sql) ⇒ Object
- #load_schema(connection_name) ⇒ Object
Instance Method Details
#create(connection_name) ⇒ Object
149 150 151 152 153 |
# File 'lib/active_record/sharding/database_tasks.rb', line 149 def create(connection_name) configuration = ActiveRecord::Base.configurations[connection_name] ActiveRecord::Tasks::DatabaseTasks.create(configuration) ActiveRecord::Base.establish_connection(configuration) end |
#drop(connection_name) ⇒ Object
155 156 157 158 |
# File 'lib/active_record/sharding/database_tasks.rb', line 155 def drop(connection_name) configuration = ActiveRecord::Base.configurations[connection_name] ActiveRecord::Tasks::DatabaseTasks.drop configuration end |
#execute(connection_name, sql) ⇒ Object
160 161 162 163 |
# File 'lib/active_record/sharding/database_tasks.rb', line 160 def execute(connection_name, sql) configuration = ActiveRecord::Base.configurations[connection_name] ActiveRecord::Base.establish_connection(configuration).connection.execute sql end |
#load_schema(connection_name) ⇒ Object
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/active_record/sharding/database_tasks.rb', line 165 def load_schema(connection_name) configuration = ActiveRecord::Base.configurations[connection_name] case when ar5? 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 |