aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorMohit Natoo <mohitnatoo@gmail.com>2017-05-10 16:04:13 +0700
committerMohit Natoo <mohitnatoo@gmail.com>2017-05-10 16:04:13 +0700
commit7bebeaf0c1c359a115f3052b9488ab3838299f63 (patch)
treec0323c829bbb08f2caaba08fe640fe79063a475b /activerecord/lib/active_record
parent97bd56e674603529d96c6f6e85d695dd24208afb (diff)
downloadrails-7bebeaf0c1c359a115f3052b9488ab3838299f63.tar.gz
rails-7bebeaf0c1c359a115f3052b9488ab3838299f63.tar.bz2
rails-7bebeaf0c1c359a115f3052b9488ab3838299f63.zip
[Foreign Key] Don't worry about the building identifier if name is already present.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb5
1 files changed, 3 insertions, 2 deletions
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 13629dee7f..16a398f631 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
@@ -1280,9 +1280,10 @@ module ActiveRecord
end
def foreign_key_name(table_name, options)
- identifier = "#{table_name}_#{options.fetch(:column)}_fk"
- hashed_identifier = Digest::SHA256.hexdigest(identifier).first(10)
options.fetch(:name) do
+ identifier = "#{table_name}_#{options.fetch(:column)}_fk"
+ hashed_identifier = Digest::SHA256.hexdigest(identifier).first(10)
+
"fk_rails_#{hashed_identifier}"
end
end