You can send the
--dry-run argument to any rake task to see what it will do.
Wouldn’t it be nice to have a similar feature for migrations so you can see what will happen without actually changing the database? This is experimental right now, but I’ve added a
migrate_dry task to the topfunky_power_tools plugin.
It works both up and down for the built-in commands (add_column, remove_column, etc.). It will fail for other arbitrary data changes, but I hope to come up with a solution for that.
topfunky$ rake migrate_dry VERSION=6 ** DRY RUN (Non-destructive) ** == AddAuthenticatedTable: reverting =========================================== -- drop_table("users") -> 0.0005s == AddAuthenticatedTable: reverted (0.0019s) ==================================
At RailsConf, Glenn Vanderburg talked about how to test your migrations.
My next workshop is in London and will be a two day hands-on workshop. Come learn about the basics of Rails, Test-Driven Development, plugin development, and more. → More Details
I’ll also be at the London Ruby Users Group on Aug 8. More details soon…