HiveBrain v1.2.0
Get Started
← Back to all entries
snippetrubyrailsCritical

How to drop columns using Rails migration

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
howdropcolumnsusingmigrationrails

Problem

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

Solution

remove_column :table_name, :column_name


For instance:

remove_column :users, :hobby


would remove the hobby Column from the users table.

Code Snippets

remove_column :table_name, :column_name
remove_column :users, :hobby

Context

Stack Overflow Q#2831059, score: 1074

Revisions (0)

No revisions yet.