mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Remove deprecated method ActiveRecord::Migrator.proper_table_name
This commit is contained in:
parent
92cf133788
commit
6da0072253
3 changed files with 4 additions and 54 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
* Remove ActiveRecord::Migrator.proper_table_name.
|
||||||
|
|
||||||
|
*Akshay Vishnoi*
|
||||||
|
|
||||||
* Fix regression on eager loading association based on SQL query rather than
|
* Fix regression on eager loading association based on SQL query rather than
|
||||||
existing column.
|
existing column.
|
||||||
|
|
||||||
|
|
|
@ -851,19 +851,6 @@ module ActiveRecord
|
||||||
migrations(migrations_paths).last || NullMigration.new
|
migrations(migrations_paths).last || NullMigration.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def proper_table_name(name, options = {})
|
|
||||||
ActiveSupport::Deprecation.warn "ActiveRecord::Migrator.proper_table_name is deprecated and will be removed in Rails 4.2. Use the proper_table_name instance method on ActiveRecord::Migration instead"
|
|
||||||
options = {
|
|
||||||
table_name_prefix: ActiveRecord::Base.table_name_prefix,
|
|
||||||
table_name_suffix: ActiveRecord::Base.table_name_suffix
|
|
||||||
}.merge(options)
|
|
||||||
if name.respond_to? :table_name
|
|
||||||
name.table_name
|
|
||||||
else
|
|
||||||
"#{options[:table_name_prefix]}#{name}#{options[:table_name_suffix]}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def migrations_paths
|
def migrations_paths
|
||||||
@migrations_paths ||= ['db/migrate']
|
@migrations_paths ||= ['db/migrate']
|
||||||
# just to not break things if someone uses: migration_path = some_string
|
# just to not break things if someone uses: migration_path = some_string
|
||||||
|
|
|
@ -333,47 +333,6 @@ class MigrationTest < ActiveRecord::TestCase
|
||||||
Reminder.reset_table_name
|
Reminder.reset_table_name
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_proper_table_name_on_migrator
|
|
||||||
reminder_class = new_isolated_reminder_class
|
|
||||||
assert_deprecated do
|
|
||||||
assert_equal "table", ActiveRecord::Migrator.proper_table_name('table')
|
|
||||||
end
|
|
||||||
assert_deprecated do
|
|
||||||
assert_equal "table", ActiveRecord::Migrator.proper_table_name(:table)
|
|
||||||
end
|
|
||||||
assert_deprecated do
|
|
||||||
assert_equal "reminders", ActiveRecord::Migrator.proper_table_name(reminder_class)
|
|
||||||
end
|
|
||||||
reminder_class.reset_table_name
|
|
||||||
assert_deprecated do
|
|
||||||
assert_equal reminder_class.table_name, ActiveRecord::Migrator.proper_table_name(reminder_class)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Use the model's own prefix/suffix if a model is given
|
|
||||||
ActiveRecord::Base.table_name_prefix = "ARprefix_"
|
|
||||||
ActiveRecord::Base.table_name_suffix = "_ARsuffix"
|
|
||||||
reminder_class.table_name_prefix = 'prefix_'
|
|
||||||
reminder_class.table_name_suffix = '_suffix'
|
|
||||||
reminder_class.reset_table_name
|
|
||||||
assert_deprecated do
|
|
||||||
assert_equal "prefix_reminders_suffix", ActiveRecord::Migrator.proper_table_name(reminder_class)
|
|
||||||
end
|
|
||||||
reminder_class.table_name_prefix = ''
|
|
||||||
reminder_class.table_name_suffix = ''
|
|
||||||
reminder_class.reset_table_name
|
|
||||||
|
|
||||||
# Use AR::Base's prefix/suffix if string or symbol is given
|
|
||||||
ActiveRecord::Base.table_name_prefix = "prefix_"
|
|
||||||
ActiveRecord::Base.table_name_suffix = "_suffix"
|
|
||||||
reminder_class.reset_table_name
|
|
||||||
assert_deprecated do
|
|
||||||
assert_equal "prefix_table_suffix", ActiveRecord::Migrator.proper_table_name('table')
|
|
||||||
end
|
|
||||||
assert_deprecated do
|
|
||||||
assert_equal "prefix_table_suffix", ActiveRecord::Migrator.proper_table_name(:table)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_proper_table_name_on_migration
|
def test_proper_table_name_on_migration
|
||||||
reminder_class = new_isolated_reminder_class
|
reminder_class = new_isolated_reminder_class
|
||||||
migration = ActiveRecord::Migration.new
|
migration = ActiveRecord::Migration.new
|
||||||
|
|
Loading…
Reference in a new issue