This project is archived and is in readonly mode.
[PATCH] Sqlite adapter's copy_table should not set :id => true if :id is not a primary key
Reported by jdunphy | January 15th, 2009 @ 09:58 PM | in 2.x
Sqlite adapter's copy_table should not set :id => true if :id is not a primary key.
We had a legacy table with a string id. Changing the table was not a good option, according to people more important than me. To recreate the table locally for development, I used a migration like the one below.
create_table :table_name, :id => false do |t|
t.column :id, :string, :limit => 40, :null => false
t.column :value, :integer
end
#later we tried to call
remove_column :table_name, :value
And upon calling remove_column, the whole thing blew up. When SQLiteAdapter tried to call copy_table, it set :id => true and wrote over the original id column.
The following commit will set :id => false if there is an :id column, but it's not a primary_key.
Comments and changes to this ticket
-
jdunphy January 15th, 2009 @ 10:08 PM
Somebody told me that patch files were preferred on single commit type patches. Here's the patch
-
Repository January 29th, 2009 @ 04:40 AM
- State changed from new to committed
(from [e6493eb9b76de73afef2706493efd090dfff4ecc]) 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] http://github.com/rails/rails/co...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Referenced by
- 1766 [PATCH] Sqlite adapter's copy_table should not set :id => true if :id is not a primary key Signed-off-by: Michael Koziarski michael@koziarski.com [#...