Project

General

Profile

Actions

Bug #16194

closed

remove_foreign_key called from RemoveAuditUserFk with wrong table name

Added by Dominic Cleal over 7 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
DB migrations
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

The 20141120140051 RemoveAuditUserFk database migration calls remove_foreign_key with the table name user rather than users. On Rails 4.2 this seems to work, but under Rails 5.0, it raises an error:

    == 20141120140051 RemoveAuditUserFk: migrating ================================
    -- remove_foreign_key(:audits, :user)
    rake aborted!
    StandardError: An error has occurred, all later migrations canceled:

    Table 'audits' has no foreign key for user
    activerecord-5.0.0/lib/active_record/connection_adapters/abstract/schema_statements.rb:970:in `foreign_key_for!'
    activerecord-5.0.0/lib/active_record/connection_adapters/abstract/schema_statements.rb:940:in `remove_foreign_key'

Docs seem to suggest it must be the table name, which is plural: http://apidock.com/rails/ActiveRecord/ConnectionAdapters/SchemaStatements/remove_foreign_key

Actions

Also available in: Atom PDF