views:

226

answers:

3

What's the syntax for dropping a database table column through a Rails migration?

A: 
remove_column :table_name, :column_name

(From the docs.)

Jordan
A: 
remove_column :table_name, :column_name

For instance:

remove_column :users, :hobby

would remove the hobby field from the users table.

Dizzy.co.uk has a really helpful migration cheatsheet.

http://dizzy.co.uk/ruby_on_rails/cheatsheets/rails-migrations

Nick Hammond
+1  A: 

Run this ruby script/generate migration RemoveFieldNameFromTableName field_name:datatype

prabu