Not sure if the migration generator will be able to cope with this or
not.
Are you declaring your string id field in the 'fields do' block in the
model? You could try removing that and manually adding the column in
the first migration (although you're passed that point now anyway so
maybe you don't need to, but for future reference)
Tom
On 30 Apr 2009, at 17:28, geoffd123 wrote:
>
> Hi All
>
> I ran hobo_migration on a table then edit the migration file to use
> the Rails :id=> false method of defining a primary key field. This
> works fine and the everything works ok in the code. (I am using
> uuidtools to generate a string id field)
>
> Then I added a belongs_to to the model and ran a hobo_migration, it
> wants to add the already existing key field and of course the
> db:migrate step fails because the field already exists.
>
> What is the way around this?
>
> First migrate after editing.
>
> class HoboMigration9 < ActiveRecord::Migration
> def self.up
> create_table :payments, :id => false do |t|
> t.string :id, :limit => 36
> t.datetime :created_at
> t.datetime :updated_at
> t.integer :subscriber_id
> end
> end
>
> def self.down
> drop_table :payments
> end
> end
>
>
>
>
> Messages output in second hobo_migration:
> ./script/generate hobo_migration
>
> ---------- Up Migration ----------
> add_column :payments, :id, :string, :limit => 36
> add_column :payments, :product_id, :integer
> ----------------------------------
>
> ---------- Down Migration --------
> remove_column :payments, :id
> remove_column :payments, :product_id
> ----------------------------------
> What now: [g]enerate migration, generate and [m]igrate now or [c]
> ancel? m
>
> Migration filename:
> (you can type spaces instead of '_' -- every little helps)
> Filename [hobo_migration_10]:
> exists db/migrate
> create db/migrate/20090430161636_hobo_migration_10.rb
> (in /home/geoffd/workspace/ducklines)
> == HoboMigration10: migrating
> ================================================
> -- add_column(:payments, :id, :string, {:limit=>36})
> rake aborted!
> An error has occurred, all later migrations canceled:
>
> SQLite3::SQLException: duplicate column name: id: ALTER TABLE
> "payments" ADD "id" varchar(36)
>
>
>
> Cheers
> Geoff
>
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Hobo
Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/hobousers?hl=en
-~----------~----~----~----~------~----~------~--~---