diff options
author | Mohit Natoo <mohitnatoo@gmail.com> | 2017-05-10 16:04:13 +0700 |
---|---|---|
committer | Mohit Natoo <mohitnatoo@gmail.com> | 2017-05-10 16:04:13 +0700 |
commit | 7bebeaf0c1c359a115f3052b9488ab3838299f63 (patch) | |
tree | c0323c829bbb08f2caaba08fe640fe79063a475b /activerecord/lib/active_record | |
parent | 97bd56e674603529d96c6f6e85d695dd24208afb (diff) | |
download | rails-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.rb | 5 |
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 |