File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ class << self
3737 def for_model ( model , old_table_name = nil )
3838 t = old_table_name || model . table_name
3939
40- primary_key_columns = Array ( model . connection . primary_key ( t ) ) . presence || rails_4_compound_primary_key ( model , t ) or
40+ primary_key_columns = Array ( model . connection . primary_key ( t ) ) . presence || sqlite_compound_primary_key ( model , t ) or
4141 raise "could not find primary key for table #{ t } in #{ model . connection . columns ( t ) . inspect } "
4242
4343 primary_key_found = false
@@ -62,9 +62,9 @@ def for_model(model, old_table_name = nil)
6262
6363 private
6464
65- # This is the old approach for Rails 4. Delete it when we drop support!
66- def rails_4_compound_primary_key ( model , table )
67- Rails ::VERSION ::MAJOR >= 5 and return nil
65+ # This is the old approach which is still needed for SQLite, at least through Rails 5
66+ def sqlite_compound_primary_key ( model , table )
67+ ! ActiveRecord :: Base . connection . class . name . match? ( /SQLite3Adapter/ ) || Rails ::VERSION ::MAJOR > 5 and return nil
6868
6969 connection = model . connection . dup
7070
You can’t perform that action at this time.
0 commit comments