From bdd42eeaf9e1858b10294764aeb99de18cfeef40 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Mon, 2 Apr 2018 17:47:35 +0900 Subject: [PATCH] Remove `ForeignKeys` module which was introduced at #32299 To solve the problem #32299, just enough to introduce `fk_ignore_pattern` option. I don't think there is a need to expose these constants. --- activerecord/lib/active_record.rb | 1 - .../abstract/schema_statements.rb | 2 +- activerecord/lib/active_record/foreign_keys.rb | 12 ------------ activerecord/lib/active_record/schema_dumper.rb | 2 +- 4 files changed, 2 insertions(+), 15 deletions(-) delete mode 100644 activerecord/lib/active_record/foreign_keys.rb diff --git a/activerecord/lib/active_record.rb b/activerecord/lib/active_record.rb index 0e1f315183..d198466dbf 100644 --- a/activerecord/lib/active_record.rb +++ b/activerecord/lib/active_record.rb @@ -43,7 +43,6 @@ module ActiveRecord autoload :DatabaseConfigurations autoload :DynamicMatchers autoload :Enum - autoload :ForeignKeys autoload :InternalMetadata autoload :Explain autoload :Inheritance 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 ef45fff9d2..e2147b7fcf 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -1324,7 +1324,7 @@ module ActiveRecord identifier = "#{table_name}_#{options.fetch(:column)}_fk" hashed_identifier = Digest::SHA256.hexdigest(identifier).first(10) - "#{ActiveRecord::ForeignKeys::PREFIX}_#{hashed_identifier}" + "fk_rails_#{hashed_identifier}" end end diff --git a/activerecord/lib/active_record/foreign_keys.rb b/activerecord/lib/active_record/foreign_keys.rb deleted file mode 100644 index 87ce3ace20..0000000000 --- a/activerecord/lib/active_record/foreign_keys.rb +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true - -module ActiveRecord - module ForeignKeys - # The prefix used by Rails to name unnamed foreign keys. - PREFIX = "fk_rails" - - # Default regular expression used by Rails to determine if a foreign key - # name was generated. - DEFAULT_IGNORE_PATTERN = /^#{PREFIX}_[0-9a-f]{10}$/ - end -end diff --git a/activerecord/lib/active_record/schema_dumper.rb b/activerecord/lib/active_record/schema_dumper.rb index 8fc2752f0c..9974c28445 100644 --- a/activerecord/lib/active_record/schema_dumper.rb +++ b/activerecord/lib/active_record/schema_dumper.rb @@ -21,7 +21,7 @@ module ActiveRecord # :singleton-method: # Specify a custom regular expression matching foreign keys which name # should not be dumped to db/schema.rb. - cattr_accessor :fk_ignore_pattern, default: ActiveRecord::ForeignKeys::DEFAULT_IGNORE_PATTERN + cattr_accessor :fk_ignore_pattern, default: /^fk_rails_[0-9a-f]{10}$/ class << self def dump(connection = ActiveRecord::Base.connection, stream = STDOUT, config = ActiveRecord::Base)