mirror of
https://github.com/github/rails.git
synced 2026-02-16 17:15:29 -05:00
Sqlite adapter's copy_table incorrectly attempts to recreate a primary key id (:id => true in the create_table) if an :id column is present, even if it isn't a primary_key.
This fix sets :id => false if there is an :id column, but it's not the primary_key. Signed-off-by: Michael Koziarski <michael@koziarski.com> [#1766 state:committed]
This commit is contained in:
committed by
Michael Koziarski
parent
feed7b4cfd
commit
e6493eb9b7
@@ -306,7 +306,7 @@ module ActiveRecord
|
||||
end
|
||||
|
||||
def copy_table(from, to, options = {}) #:nodoc:
|
||||
options = options.merge(:id => !columns(from).detect{|c| c.name == 'id'}.nil?)
|
||||
options = options.merge(:id => (!columns(from).detect{|c| c.name == 'id'}.nil? && 'id' == primary_key(from).to_s))
|
||||
create_table(to, options) do |definition|
|
||||
@definition = definition
|
||||
columns(from).each do |column|
|
||||
|
||||
Reference in New Issue
Block a user