ActiveRecord migrations in a single transaction?

Is it possible to make Migrations occur in a single transaction, so
that if the rake fails, it doesn’t leave the database in a broken
state, with half the changes made, and the other half incomplete?

Obviously, this depends on the database itself supporting transactions,
but I’m using Postgres.

Stuart G. wrote:

Is it possible to make Migrations occur in a single transaction, so
that if the rake fails, it doesn’t leave the database in a broken
state, with half the changes made, and the other half incomplete?

Obviously, this depends on the database itself supporting transactions,
but I’m using Postgres.

I wrap my migrations in a transaction using postgresql, and it seems to
work fine.


Jim M., http://blog.wolfman.com

Me too.

But you need a database backend that will transact DDL changes. Not
all do. Postgres for sure does, and now I don’t have any half-made
transactions anymore.

I can give you more details if needed.

Bye,

Guy.

On 10/23/06, Jim M. [email protected] wrote:

I wrap my migrations in a transaction using postgresql, and it seems to work fine.


Jim M., http://blog.wolfman.com


Family management on rails: http://www.famundo.com - coming soon!
My development related blog: http://devblog.famundo.com

Stuart G. wrote:

Is it possible to make Migrations occur in a single transaction, so that if
the rake fails, it doesn’t leave the database in a broken state, with half
the changes made, and the other half incomplete?

Obviously, this depends on the database itself supporting transactions, but
I’m using Postgres.

The easiest way for you is to use transactional_migrations plugin. Thus
you
won’t need to put explicit BEGIN and COMMIT DDL statements in
migrations.

http://www.redhillconsulting.com.au/rails_plugins.html#transactional_migrations


Sava C.

Hello:
You wrote in another thread, now outdated, about a way for getting
decimal support for ActiveRecord, in version 1.1.6.
Is there a way of having that code?
Thanks in advance.

Thanks Sava, this is what I went for in the end …

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs