Project

General

Profile

Bug #16194

remove_foreign_key called from RemoveAuditUserFk with wrong table name

Added by Dominic Cleal almost 4 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
DB migrations
Target version:
Difficulty:
Triaged:
Bugzilla link:
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

Associated revisions

Revision aeb74d31 (diff)
Added by Dominic Cleal almost 4 years ago

fixes #16194 - correct table name in remove_foreign_key call

History

#1 Updated by The Foreman Bot almost 4 years ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/3747 added

#2 Updated by Dominic Cleal almost 4 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#3 Updated by Dominic Cleal almost 4 years ago

  • Legacy Backlogs Release (now unused) set to 160

Also available in: Atom PDF