Project

General

Profile

Actions

Refactor #14094

closed

Replace DB migration foreign_keys calls with foreign_key_exists?

Added by Dominic Cleal about 8 years ago. Updated over 5 years ago.

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

Description

In Rail 4.2 and higher, where native foreign key support replaces Foreigner, the "foreign_keys" call inside a DB migration should be avoided as it will throw an exception on databases (SQLite) that don't support FKs.

https://github.com/rails/rails/blob/6298ac705da92cc793cbf40dd91484d34e01d255/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb#L671

In Foreigner, it returned [] on SQLite. In #13244 (Rails 4.2) I'll add a compatibility layer with a deprecation warning, but our migrations that use this to check whether a key exists should just use the foreign_key_exists? method for better compatibility.


Related issues 1 (0 open1 closed)

Blocks Foreman - Feature #13244: Upgrade Ruby on Rails to 4.2ClosedDominic Cleal01/15/2016Actions
Actions #1

Updated by Dominic Cleal about 8 years ago

Actions #2

Updated by The Foreman Bot about 8 years ago

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

Updated by Dominic Cleal about 8 years ago

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

Updated by Dominic Cleal about 8 years ago

  • translation missing: en.field_release set to 136
Actions

Also available in: Atom PDF