Migrations are always run inside transaction

99 views
Skip to first unread message

Илья Рассадин

unread,
Feb 7, 2018, 2:30:28 PM2/7/18
to Mojolicious
Hi!

On my new project I finally started using Mojo::Pg::Migrations but ran
into a problem.

All migrations are wrapped within transactions. But some schema changes,
such as enum type modifications can not be run inside transactions.

And code falls with message

DBD::Pg::st execute failed: ERROR:  ALTER TYPE ... ADD cannot run inside
a transaction block at
/path/to/project/local/lib/perl5/Mojo/Pg/Migrations.pm line 66

As I can see, for now there is no way to disable transaction for some
migrations.

So, what do you think, is it a good feature?

Other frameworks, such as rails and laravel implemented this due to the
same idea,

https://github.com/laravel/framework/pull/22757

https://github.com/rails/rails/pull/9507

--

Best regards

Ilya Rassadin.

Sebastian Riedel

unread,
Feb 7, 2018, 2:45:44 PM2/7/18
to mojol...@googlegroups.com
> All migrations are wrapped within transactions. But some schema changes,
> such as enum type modifications can not be run inside transactions.
>
> And code falls with message
>
> DBD::Pg::st execute failed: ERROR: ALTER TYPE ... ADD cannot run inside a
> transaction block at /path/to/project/local/lib/perl5/Mojo/Pg/Migrations.pm
> line 66
>
> As I can see, for now there is no way to disable transaction for some
> migrations.
>
> So, what do you think, is it a good feature?

Most likely not worth it, since it would require huge code changes. And for enum
there are workarounds that work in transactions (rename type, create type, add
column, remove column).

--
Sebastian Riedel
http://mojolicio.us
http://github.com/kraih
http://twitter.com/kraih
Reply all
Reply to author
Forward
0 new messages