From 70937d331f3e22bc25daa8889f07217b3b7095ee Mon Sep 17 00:00:00 2001 From: Nathan Long Date: Wed, 23 Aug 2023 05:40:16 -0400 Subject: [PATCH] Improve docs for migration attrs (#551) --- lib/ecto/migration.ex | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/ecto/migration.ex b/lib/ecto/migration.ex index 1ccc49c6..0c62d07e 100644 --- a/lib/ecto/migration.ex +++ b/lib/ecto/migration.ex @@ -812,10 +812,12 @@ defmodule Ecto.Migration do utilizes advisory locks to faciliate running migrations one at a time even across multiple nodes. For example: - # Config the Repo (PostgreSQL example) + ### Config file (PostgreSQL) + config MyApp.Repo, migration_lock: :pg_advisory_lock - # Migrate with your concurrent operation + ### Migration file + defmodule MyRepo.Migrations.CreateIndexes do use Ecto.Migration @disable_ddl_transaction true @@ -825,6 +827,11 @@ defmodule Ecto.Migration do end end + Alternately, you can add `@disable_migration_lock true` to your migration file. + This would mean that different nodes in a multi-node setup could run the same + migration at once. It is recommended to isolate your migrations to a single node + when using concurrent index creation without an advisory lock. + ## Index types When creating an index, the index type can be specified with the `:using`