mojolicious / mojo-pg

Mojolicious :heart: PostgreSQL
https://metacpan.org/release/Mojo-Pg
Artistic License 2.0
99 stars 46 forks source link

Migrations with commands that can't run in transaction #35

Closed kak-tus closed 7 years ago

kak-tus commented 7 years ago

Hello.

How to use migrations with commands, that can't run in transaction? As example CREATE TABLESPACE.

For example:

  1. We have some table1.
  2. We want move it to some tablespace.
  3. We create tablespace manually (because we can't do it in migration).
  4. Then we do ALTER TABLE table1 SET TABLESPACE some_tablespace;

But when we want to do this migration in another postgresql environment (test database) - we can't do that, because there is no this tablespace.

May be, that is a good idea to add some keyword to migration description that can run current migration without transaction?

-- 1 up no_transaction
CREATE TABLESPACE
jberger commented 7 years ago

I haven't actually tried it but I've been told that there is also a problem with changing the values of an enum type in a transactional ddl.

kak-tus commented 7 years ago

For enums where is some workaround: rename enum, create new enum, update type to new enum, delete old enum, rename new enum.

kraih commented 7 years ago

I have not used tablespaces yet and have no solution for this.

kraih commented 7 years ago

Guess we might have to accept that there is no solution for this.