#382 ✓resolved
bronson

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

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.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

People watching this ticket

Pages