Migration generator can't remove surrogate id
Reported by bronson | February 18th, 2009 @ 07:51 AM | in Hobo 1.0 - Final
When I try to remove the typical Rails surrogate 'id' column using the Hobo migration generator, it produces invalid results.
Steps to reproduce:
Create a new model with a regular id.
class Model < ActiveRecord::Base
hobo_model # Don't put anything above this
fields do
permid :integer
end
end
Generate the migration and migrate.
Now add 'set_primary_key "permid"' to the model and generate again. You get this:
class NoSurrogateKey < ActiveRecord::Migration
def self.up
add_column :models, :permid, :integer
remove_column :models, :id
end
def self.down
remove_column :models, :permid
add_column :models, :id,
end
end
First, it's trying to add a column that already exists. The lines involving :permid should be omitted.
Second, that final line in self.down is invalid. Hobo neglects to print ':integer'
Comments and changes to this ticket
-
bronson February 19th, 2009 @ 04:32 AM
And now that I've removed the surrogate ID, every subsequent migration tries to:
add_column :models, :permid, :integer
even though it already exists!
-
Tom Locke March 12th, 2009 @ 10:54 AM
- Milestone set to Hobo 1.0 - Final
- State changed from new to open
-
Bryan Larsen May 11th, 2009 @ 07:26 PM
- Tag changed from migration-generator, migrations to defect, migration-generator, migrations
I pushed some more support for alternately named primary keys to edge. Could you please test on your app?
thanks.
-
Bryan Larsen May 13th, 2009 @ 02:43 AM
- State changed from open to resolved
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป