Sha256: fdb6d34179e2807f8b98a5462777051a6c64b0f4fa0972556f701eb71063fa2a
Contents?: true
Size: 1.52 KB
Versions: 22
Compression:
Stored size: 1.52 KB
Contents
require 'arjdbc/tasks/database_tasks' module ActiveRecord::Tasks DatabaseTasks.module_eval do # @override patched to adapt jdbc configuration def each_current_configuration(environment, name = nil) environments = [environment] environments << 'test' if environment == 'development' environments.each do |env| ActiveRecord::Base.configurations.configs_for(env_name: env).each do |db_config| next if name && name != db_config.name if db_config.database yield adapt_jdbc_config(db_config), db_config.name, env end end end end # @override patched to adapt jdbc configuration def each_local_configuration ActiveRecord::Base.configurations.configs_for.each do |db_config| next unless db_config.database if local_database?(db_config) yield adapt_jdbc_config(db_config) else $stderr.puts "This task only modifies local databases. #{db_config.database} is on a remote host." end end end private def adapt_jdbc_config(db_config) if db_config.adapter.start_with? 'jdbc' config = db_config.configuration_hash.merge(adapter: db_config.adapter.sub(/^jdbc/, '')) db_config = ActiveRecord::DatabaseConfigurations::HashConfig.new(db_config.env_name, db_config.name, config) end db_config end end MySQLDatabaseTasks.class_eval do def error_class ActiveRecord::JDBCError end end if const_defined?(:MySQLDatabaseTasks) end
Version data entries
22 entries across 22 versions & 2 rubygems