未验证 提交 abb810b9 编写于 作者: G Guillermo Iguaran 提交者: GitHub

Merge pull request #32415 from kamipo/remove_foreign_keys_module

Remove `ForeignKeys` module which was introduced at #32299
......@@ -43,7 +43,6 @@ module ActiveRecord
autoload :DatabaseConfigurations
autoload :DynamicMatchers
autoload :Enum
autoload :ForeignKeys
autoload :InternalMetadata
autoload :Explain
autoload :Inheritance
......
......@@ -1324,7 +1324,7 @@ def foreign_key_name(table_name, options)
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
......
# 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
......@@ -21,7 +21,7 @@ class SchemaDumper #:nodoc:
# :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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册