DEV Community

Malki Davis
Malki Davis

Posted on

Make remove column a reversible migration

Today I learned in order to make a remove_column migration reversible (which I need often when tinkering in development with the perfect database setup) we need to add the the type which is not required for migrating the database.

remove_column :table, :column, :type
Enter fullscreen mode Exit fullscreen mode

For just a few more characters, the investment definitely pays off in case of the need to reverse the migration (even if it's not only in development).

Top comments (2)

Collapse
 
tutelaris profile image
Klim Markelov

Or you can explicitly specify up and down methods 🙂

Collapse
 
mxdavis profile image
Malki Davis

of course! much more typing there though ;)