Post

Always test rolling back when creating a migration

Making a migration means changing the database, which is always a risky thing. Having a backup of our database is one thing, but it is better if we don’t resort to it.

We should always test rolling back a migration in development. If it doesn’t rollback we can fix it and move on. This is how it is done in Rails:

1
2
rails db:migrate
rails db:rollback

It is easy as that and it doesn’t hurt to do it a couple of times in development. Because when you receive an error while trying to rollback in production you will start crying.

This post is licensed under CC BY-NC 4.0 by the author.