# Migration for change or remove table column

**URL:** <https://www.ruby-forum.com/t/migration-for-change-or-remove-table-column/145885>\
**Category:** Rails\
**Created:** [August 14, 2008, 7:01pm UTC](https://www.ruby-forum.com/t/migration-for-change-or-remove-table-column/145885 "2008-08-14T19:01:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![txapelgorri](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5f8ce5/32.png) [@txapelgorri](https://www.ruby-forum.com/u/txapelgorri)\
**Post date:** [August 14, 2008, 7:01pm UTC](https://www.ruby-forum.com/t/migration-for-change-or-remove-table-column/145885/1 "2008-08-14T19:01:25Z")

</div>

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?.

---

<div class="post-metadata">

**Author:** ![txapelgorri](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5f8ce5/32.png) [@txapelgorri](https://www.ruby-forum.com/u/txapelgorri)\
**Post date:** [August 14, 2008, 7:30pm UTC](https://www.ruby-forum.com/t/migration-for-change-or-remove-table-column/145885/2 "2008-08-14T19:30:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![txapelgorri](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5f8ce5/32.png) [@txapelgorri](https://www.ruby-forum.com/u/txapelgorri)\
**Post date:** [August 15, 2008, 1:32pm UTC](https://www.ruby-forum.com/t/migration-for-change-or-remove-table-column/145885/3 "2008-08-15T13:32:30Z")

</div>

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. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![txapelgorri](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5f8ce5/32.png) [@txapelgorri](https://www.ruby-forum.com/u/txapelgorri)\
**Post date:** [August 15, 2008, 9:05pm UTC](https://www.ruby-forum.com/t/migration-for-change-or-remove-table-column/145885/4 "2008-08-15T21:05:48Z")

</div>

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

Cheers, Ibon.
