Are migrations executed within a transaction?

[Rails] Are migrations executed within a transaction?

As I’m writing migration changes to the database, I find that rollingback is a pain sometimes, because of writing self.down(). When it fails, I have to reset the database. While this really isn’t a problem since no real data is in there (and all the fixtures are added automatically), it is an extra step.

I figured migrations would be executed within a transaction, but apparently, it’s not. This was the only link I could find about it, and the guy just says you can’t. Anyone know why you can’t?


One thought on “Are migrations executed within a transaction?

  1. I’m not a DB expert. But I don’t imagine that modifying table structures is something that can be rolled back. It’s not the same as inserting new data into a table.Thus, no transaction. Maybe if you looked up the definition of the ACID properties for a transcations, it would make sense that modifying a table structure does not follow those properties, and thus does not qualify to be a transaction.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s