I read in various places that although migrations aren’t transactional,
you need to do is wrap you migration method in “ActiveRecord::
to make the self.up or self.down transactional. In my experience (Rails
PostgreSQL), this doesn’t work very well. If my migration hits an
exception, any tables that were touched remain modified. Even if I fix
error in my migration, I can’t just re-run the migration since my schema
doesn’t match what the migration is expecting. I also can’t migrate
since it seems like the up migration wasn’t recorded.
Here is a link to another write-up about this same problem.
Am I missing something or is there really no way to protect the DB from
failed migrations? It can be a real pain to go into the DB an manually
everything in order to run the migration after an exception. Does
have any suggestions other than being more careful when I write