method
mismatched_foreign_key
rails latest stable - Class:
ActiveRecord::ConnectionAdapters
mismatched_foreign_key(message)private
No documentation available.
# File activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb, line 806
def mismatched_foreign_key(message)
match = /
(?:CREATE|ALTER)\s+TABLE\s*(?:`?\w+`?\.)?`?(?<table>\w+)`?.+?
FOREIGN\s+KEY\s*\(`?(?<foreign_key>\w+)`?\)\s*
REFERENCES\s*(`?(?<target_table>\w+)`?)\s*\(`?(?<primary_key>\w+)`?\)
/mi.match(message)
options = {
message: message,
}
if match
options[:table] = match[:table]
options[:foreign_key] = match[:foreign_key]
options[:target_table] = match[:target_table]
options[:primary_key] = match[:primary_key]
options[:primary_key_column] = column_for(match[:target_table], match[:primary_key])
end
MismatchedForeignKey.new(options)
end