diff options
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/internal_metadata.rb | 13 | ||||
-rw-r--r-- | activerecord/lib/active_record/model_schema.rb | 4 |
2 files changed, 15 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/internal_metadata.rb b/activerecord/lib/active_record/internal_metadata.rb index cb4b1fc47c..81db96bffd 100644 --- a/activerecord/lib/active_record/internal_metadata.rb +++ b/activerecord/lib/active_record/internal_metadata.rb @@ -14,6 +14,10 @@ module ActiveRecord "#{table_name_prefix}#{ActiveRecord::Base.internal_metadata_table_name}#{table_name_suffix}" end + def original_table_name + "#{table_name_prefix}active_record_internal_metadatas#{table_name_suffix}" + end + def []=(key, value) first_or_initialize(key: key).update_attributes!(value: value) end @@ -26,8 +30,17 @@ module ActiveRecord ActiveSupport::Deprecation.silence { connection.table_exists?(table_name) } end + def original_table_exists? + # This method will be removed in Rails 5.1 + # Since it is only necessary when `active_record_internal_metadatas` could exist + ActiveSupport::Deprecation.silence { connection.table_exists?(original_table_name) } + end + # Creates an internal metadata table with columns +key+ and +value+ def create_table + if original_table_exists? + connection.rename_table(original_table_name, table_name) + end unless table_exists? key_options = connection.internal_string_options_for_primary_key diff --git a/activerecord/lib/active_record/model_schema.rb b/activerecord/lib/active_record/model_schema.rb index 722d7b5fce..ee52c3ae02 100644 --- a/activerecord/lib/active_record/model_schema.rb +++ b/activerecord/lib/active_record/model_schema.rb @@ -44,9 +44,9 @@ module ActiveRecord ## # :singleton-method: - # Accessor for the name of the internal metadata table. By default, the value is "active_record_internal_metadatas" + # Accessor for the name of the internal metadata table. By default, the value is "ar_internal_metadata" class_attribute :internal_metadata_table_name, instance_accessor: false - self.internal_metadata_table_name = "active_record_internal_metadatas" + self.internal_metadata_table_name = "ar_internal_metadata" ## # :singleton-method: |