Support config to disable_ddl_transaction

32 views
Skip to first unread message

Fabian Becker

unread,
Apr 4, 2025, 10:04:27 AMApr 4
to elixir-ecto
Hi there,

We have a large app that will migrate to CockroachDB. CockroachDB uses the PostgreSQL wire protocol and so the Postgrex adapter works perfectly fine. In the meantime we need to support both PostgreSQL and CockroachDB and want to run Ecto migrations against both.

Cockroach however does not support running DDL migrations inside of a transaction

> CockroachDB only guarantees atomicity for schema changes within single statement transactions, either implicit transactions or in an explicit transaction with a single schema change statement.

We would have to set `disable_migration_lock` and `disable_ddl_transaction` on all migrations. There is a config option to disable `migration_lock` that can be set on the Repo, but there's no such option to globally disable ddl_transaction. 

Proposal:
Add new config `ddl_transaction` that disables the ddl_transaction for all migrations

Happy to do the work if this is accepted.

Thanks!

José Valim

unread,
Apr 4, 2025, 10:15:03 AMApr 4
to elixi...@googlegroups.com
My suggestion would be to create a new module, MyApp.Migration, which does:

```
defmodule MyApp.Migration do
  defmacro __using__(_opts) do
    quote do
      use Ecto.Migration
  end
end
```

and then use it in your migrations. IIRC, you can even configure Phoenix generators to use your custom module.


--
You received this message because you are subscribed to the Google Groups "elixir-ecto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-ecto...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/elixir-ecto/57ee5004-6aa2-4301-aabf-ff4d828a4c73n%40googlegroups.com.

Fabian Becker

unread,
Apr 4, 2025, 10:23:34 AMApr 4
to elixi...@googlegroups.com
In the current phase we need to support running migrations against both database systems. So using a custom Ecto.Migration module would override this for both systems.
 
It’s unclear why there’s an option for migration_lock but not for ddl_transaction in the first place?

Cheers,
Fabian
You received this message because you are subscribed to a topic in the Google Groups "elixir-ecto" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elixir-ecto/-ZxbeTQr6Hc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elixir-ecto...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/elixir-ecto/CAGnRm4J%2BBE%2BYOOeMbjDWUPPjp2rv5tHxbuxFEB-JCKVDhYEf-A%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages