diff options
author | Matthew Draper <matthew@trebex.net> | 2017-01-20 01:02:03 +1030 |
---|---|---|
committer | Matthew Draper <matthew@trebex.net> | 2017-01-20 01:02:03 +1030 |
commit | 893d5fb0a24bc69b07574924d78ca7f9826f9403 (patch) | |
tree | 0c7d9dea4715e65f5b1a6ea51b33758ce79fbfb4 | |
parent | 7b4514c6ab2703b9a9b6574f3559cae722a33d4f (diff) | |
download | rails-893d5fb0a24bc69b07574924d78ca7f9826f9403.tar.gz rails-893d5fb0a24bc69b07574924d78ca7f9826f9403.tar.bz2 rails-893d5fb0a24bc69b07574924d78ca7f9826f9403.zip |
Revert "Merge pull request #27718 from kamipo/remove_internal_public_methods"
This reverts commit 39c77eb1843f79925c7195e8869afc7cb7323682, reversing
changes made to 9f6f51be78f8807e18fc6562c57af2fdbf8ccb56.
6 files changed, 18 insertions, 13 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 4b8e8f555d..85a14e5966 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -2,11 +2,6 @@ *Ryuta Kamizono* -* Remove `initialize_schema_migrations_table` and `initialize_internal_metadata_table` - internal public methods. - - *Ryuta Kamizono* - * Place generated migrations into the path set by `config.paths["db/migrate"]`. *Kevin Glowacz* diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb index 95725cd883..1bdc086380 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -1008,6 +1008,16 @@ module ActiveRecord end end + # Should not be called normally, but this operation is non-destructive. + # The migrations module handles this automatically. + def initialize_schema_migrations_table + ActiveRecord::SchemaMigration.create_table + end + + def initialize_internal_metadata_table + ActiveRecord::InternalMetadata.create_table + end + def internal_string_options_for_primary_key # :nodoc: { primary_key: true } end diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index 339332a60d..31c2397bc9 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -1107,8 +1107,8 @@ module ActiveRecord validate(@migrations) - ActiveRecord::SchemaMigration.create_table - ActiveRecord::InternalMetadata.create_table + Base.connection.initialize_schema_migrations_table + Base.connection.initialize_internal_metadata_table end def current_version diff --git a/activerecord/lib/active_record/schema.rb b/activerecord/lib/active_record/schema.rb index 5104427339..7a2bc9c8af 100644 --- a/activerecord/lib/active_record/schema.rb +++ b/activerecord/lib/active_record/schema.rb @@ -48,7 +48,7 @@ module ActiveRecord instance_eval(&block) if info[:version].present? - ActiveRecord::SchemaMigration.create_table + initialize_schema_migrations_table connection.assume_migrated_upto_version(info[:version], migrations_paths) end diff --git a/activerecord/test/cases/adapters/mysql2/schema_migrations_test.rb b/activerecord/test/cases/adapters/mysql2/schema_migrations_test.rb index 605baa9905..fa54aac6b3 100644 --- a/activerecord/test/cases/adapters/mysql2/schema_migrations_test.rb +++ b/activerecord/test/cases/adapters/mysql2/schema_migrations_test.rb @@ -16,7 +16,7 @@ class SchemaMigrationsTest < ActiveRecord::Mysql2TestCase table_name = ActiveRecord::SchemaMigration.table_name connection.drop_table table_name, if_exists: true - ActiveRecord::SchemaMigration.create_table + connection.initialize_schema_migrations_table assert connection.column_exists?(table_name, :version, :string, collation: "utf8_general_ci") end @@ -27,7 +27,7 @@ class SchemaMigrationsTest < ActiveRecord::Mysql2TestCase table_name = ActiveRecord::InternalMetadata.table_name connection.drop_table table_name, if_exists: true - ActiveRecord::InternalMetadata.create_table + connection.initialize_internal_metadata_table assert connection.column_exists?(table_name, :key, :string, collation: "utf8_general_ci") end diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb index c728cc9669..4edb807bbb 100644 --- a/activerecord/test/cases/migration_test.rb +++ b/activerecord/test/cases/migration_test.rb @@ -43,10 +43,10 @@ class MigrationTest < ActiveRecord::TestCase ActiveRecord::Base.table_name_prefix = "" ActiveRecord::Base.table_name_suffix = "" - ActiveRecord::SchemaMigration.create_table - ActiveRecord::SchemaMigration.delete_all + ActiveRecord::Base.connection.initialize_schema_migrations_table + ActiveRecord::Base.connection.execute "DELETE FROM #{ActiveRecord::Migrator.schema_migrations_table_name}" - %w(things awesome_things prefix_things_suffix p_awesome_things_s).each do |table| + %w(things awesome_things prefix_things_suffix p_awesome_things_s ).each do |table| Thing.connection.drop_table(table) rescue nil end Thing.reset_column_information |