Migration for change or remove table column

Hi:

I made a migration to create a table and all the columns. Going ahead
with the development, I realize that I need to change the type of one
column from binary to string (to storage photos paths, instead of
photos themselves).

I tried “script/generate migration RemovePhotoFromPerson
photo:binary” (this creates appropriate migration file successfully,
remove_column and add_column at self.up and self.down respectively),
but rake db:migrate does nothing :S
I also have try manually changing column type with “script/generate
migration ChangePhotoOnPerson”, then editing “db/migrate/
00X_change_photo_on_person.rb”, adding:

def self.up
change_column :people, :photo, :string
end

def self.down
change_column :people, :photo, :binary
end

But still, nothing seems to happen.

Question is: how do I remove/change this column?.

On 14 Aug 2008, at 18:00, txapelgorri wrote:

Hi:

I made a migration to create a table and all the columns. Going ahead
with the development, I realize that I need to change the type of one
column from binary to string (to storage photos paths, instead of
photos themselves).

Sounds like you’ve already ran the migration. Once you’ve done so,
rails won’t notice changes made to the migration and rails db:migrate
will do nothing.
Easiest way out is probably just to edit the schema_info table and set
the version to the one before this migration.

Or run rake db:migrate:redo after commenting out all actions in
self.down. Note that if you’re using not rails 2.1 then migrate to
version below current and then migrate to current version again.

On Aug 14, 8:29 pm, Frederick C. [email protected]

Wow Frederick!, you were completely right!. The value of schema_info
was wrong (too much generate/destroy I suppose :slight_smile: ). The migration has
work like a charm, so thank very much!.

Cheers, Ibon.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs