Permalink
Browse files

Replace deprecated `#load_schema` with `#load_schema_for`.

  • Loading branch information...
senny committed Dec 23, 2014
1 parent 0587070 commit ad783136d747f73329350b9bb5a5e17c8f8800da
@@ -1,3 +1,8 @@
* Replace deprecated `ActiveRecord::Tasks::DatabaseTasks#load_schema` with
`ActiveRecord::Tasks::DatabaseTasks#load_schema_for`.
*Yves Senn*
* Fixes bug with 'ActiveRecord::Type::Numeric' that causes negative values to
be marked as having changed when set to the same negative value.
@@ -319,7 +319,7 @@ db_namespace = namespace :db do
begin
should_reconnect = ActiveRecord::Base.connection_pool.active_connection?
ActiveRecord::Schema.verbose = false
ActiveRecord::Tasks::DatabaseTasks.load_schema_for ActiveRecord::Base.configurations['test'], :ruby, ENV['SCHEMA']
ActiveRecord::Tasks::DatabaseTasks.load_schema ActiveRecord::Base.configurations['test'], :ruby, ENV['SCHEMA']
ensure
if should_reconnect
ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations[ActiveRecord::Tasks::DatabaseTasks.env])
@@ -329,7 +329,7 @@ db_namespace = namespace :db do
# desc "Recreate the test database from an existent structure.sql file"
task :load_structure => %w(db:test:purge) do
ActiveRecord::Tasks::DatabaseTasks.load_schema_for ActiveRecord::Base.configurations['test'], :sql, ENV['SCHEMA']
ActiveRecord::Tasks::DatabaseTasks.load_schema ActiveRecord::Base.configurations['test'], :sql, ENV['SCHEMA']
end
# desc "Recreate the test database from a fresh schema"
@@ -188,27 +188,7 @@ def structure_load(*arguments)
class_for_adapter(configuration['adapter']).new(*arguments).structure_load(filename)
end
def load_schema(format = ActiveRecord::Base.schema_format, file = nil)
ActiveSupport::Deprecation.warn(<<-MSG.squish)
This method will act on a specific connection in the future.
To act on the current connection, use `load_schema_current` instead.
MSG
load_schema_current(format, file)
end
def schema_file(format = ActiveSupport::Base.schema_format)
case format
when :ruby
File.join(db_dir, "schema.rb")
when :sql
File.join(db_dir, "structure.sql")
end
end
# This method is the successor of +load_schema+. We should rename it
# after +load_schema+ went through a deprecation cycle. (Rails > 4.2)
def load_schema_for(configuration, format = ActiveRecord::Base.schema_format, file = nil) # :nodoc:
def load_schema(configuration, format = ActiveRecord::Base.schema_format, file = nil) # :nodoc:
file ||= schema_file(format)
case format
@@ -224,6 +204,23 @@ def load_schema_for(configuration, format = ActiveRecord::Base.schema_format, fi
end
end
def load_schema_for(*args)
ActiveSupport::Deprecation.warn(<<-MSG.squish)
This method was renamed to `#load_schema` and will be removed in the future.
Use `#load_schema` instead.
MSG
load_schema *args
end
def schema_file(format = ActiveSupport::Base.schema_format)
case format
when :ruby
File.join(db_dir, "schema.rb")
when :sql
File.join(db_dir, "structure.sql")
end
end
def load_schema_current_if_exists(format = ActiveRecord::Base.schema_format, file = nil, environment = env)
if File.exist?(file || schema_file(format))
load_schema_current(format, file, environment)
@@ -232,7 +229,7 @@ def load_schema_current_if_exists(format = ActiveRecord::Base.schema_format, fil
def load_schema_current(format = ActiveRecord::Base.schema_format, file = nil, environment = env)
each_current_configuration(environment) { |configuration|
load_schema_for configuration, format, file
load_schema configuration, format, file
}
ActiveRecord::Base.establish_connection(environment.to_sym)
end

0 comments on commit ad78313

Please sign in to comment.