Permalink
Browse files

Merge pull request #28293 from kamipo/remove_useless_migrator_schema_…

…migrations_table_name

Remove useless `Migrator.schema_migrations_table_name`
  • Loading branch information...
eileencodes committed Mar 5, 2017
2 parents 6ef074a + 60440a6 commit 45b64bb6a837a6405567c94d2b719e232cd56e86
@@ -996,7 +996,7 @@ def dump_schema_information #:nodoc:
end
def insert_versions_sql(versions) # :nodoc:
- sm_table = quote_table_name(ActiveRecord::Migrator.schema_migrations_table_name)
+ sm_table = quote_table_name(ActiveRecord::SchemaMigration.table_name)
if versions.is_a?(Array)
sql = "INSERT INTO #{sm_table} (version) VALUES\n"
@@ -1025,7 +1025,7 @@ def internal_string_options_for_primary_key # :nodoc:
def assume_migrated_upto_version(version, migrations_paths)
migrations_paths = Array(migrations_paths)
version = version.to_i
- sm_table = quote_table_name(ActiveRecord::Migrator.schema_migrations_table_name)
+ sm_table = quote_table_name(ActiveRecord::SchemaMigration.table_name)
migrated = select_values("SELECT version FROM #{sm_table}").map(&:to_i)
versions = ActiveRecord::Migrator.migration_files(migrations_paths).map do |file|
@@ -1022,12 +1022,8 @@ def open(migrations_paths)
new(:up, migrations(migrations_paths), nil)
end
- def schema_migrations_table_name
- SchemaMigration.table_name
- end
-
def get_all_versions(connection = Base.connection)
- if connection.table_exists?(schema_migrations_table_name)
+ if SchemaMigration.table_exists?
SchemaMigration.all.map { |x| x.version.to_i }.sort
else
[]
@@ -337,20 +337,20 @@ def migrate(x)
end
def test_schema_migrations_table_name
- original_schema_migrations_table_name = ActiveRecord::Migrator.schema_migrations_table_name
+ original_schema_migrations_table_name = ActiveRecord::Base.schema_migrations_table_name
- assert_equal "schema_migrations", ActiveRecord::Migrator.schema_migrations_table_name
+ assert_equal "schema_migrations", ActiveRecord::SchemaMigration.table_name
ActiveRecord::Base.table_name_prefix = "prefix_"
ActiveRecord::Base.table_name_suffix = "_suffix"
Reminder.reset_table_name
- assert_equal "prefix_schema_migrations_suffix", ActiveRecord::Migrator.schema_migrations_table_name
+ assert_equal "prefix_schema_migrations_suffix", ActiveRecord::SchemaMigration.table_name
ActiveRecord::Base.schema_migrations_table_name = "changed"
Reminder.reset_table_name
- assert_equal "prefix_changed_suffix", ActiveRecord::Migrator.schema_migrations_table_name
+ assert_equal "prefix_changed_suffix", ActiveRecord::SchemaMigration.table_name
ActiveRecord::Base.table_name_prefix = ""
ActiveRecord::Base.table_name_suffix = ""
Reminder.reset_table_name
- assert_equal "changed", ActiveRecord::Migrator.schema_migrations_table_name
+ assert_equal "changed", ActiveRecord::SchemaMigration.table_name
ensure
ActiveRecord::Base.schema_migrations_table_name = original_schema_migrations_table_name
Reminder.reset_table_name

1 comment on commit 45b64bb

@jasnow

This comment has been minimized.

Show comment
Hide comment
@jasnow

jasnow Mar 8, 2017

FYI: Know this in not part of rails repo, but lots of people use database_cleaner.
Regression: DatabaseCleaner/database_cleaner#476
PR: DatabaseCleaner/database_cleaner#477

jasnow commented on 45b64bb Mar 8, 2017

FYI: Know this in not part of rails repo, but lots of people use database_cleaner.
Regression: DatabaseCleaner/database_cleaner#476
PR: DatabaseCleaner/database_cleaner#477

Please sign in to comment.