1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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.
This commit is contained in:
Ryuta Kamizono 2018-04-02 17:47:35 +09:00
parent 09b2348f7f
commit bdd42eeaf9
4 changed files with 2 additions and 15 deletions

View file

@ -43,7 +43,6 @@ module ActiveRecord
autoload :DatabaseConfigurations
autoload :DynamicMatchers
autoload :Enum
autoload :ForeignKeys
autoload :InternalMetadata
autoload :Explain
autoload :Inheritance

View file

@ -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

View file

@ -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

View file

@ -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)