This project is archived and is in readonly mode.

#1766 ✓committed
jdunphy

[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

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

Pages