Skip to content

Fix concurrent index migrations with schema-driven multitenancy #610#685

Closed
RylandBangerter85 wants to merge 0 commit intoash-project:mainfrom
RylandBangerter85:fix-concurrent-index-multitenancy
Closed

Fix concurrent index migrations with schema-driven multitenancy #610#685
RylandBangerter85 wants to merge 0 commit intoash-project:mainfrom
RylandBangerter85:fix-concurrent-index-multitenancy

Conversation

@RylandBangerter85
Copy link

@RylandBangerter85 RylandBangerter85 commented Feb 4, 2026

  • Detect migrations with @disable_ddl_transaction attribute
  • Run concurrent index migrations outside transaction context
  • Use Ecto.Adapters.SQL.checkout to get fresh connection
  • Add comprehensive test suite for concurrent index scenarios
  • Maintain backward compatibility with regular migrations

Fixes issue where CREATE INDEX CONCURRENTLY fails when creating tenants

Contributor checklist

Leave anything that you believe does not apply unchecked.

  • I accept the AI Policy, or AI was not used in the creation of this PR.
  • Bug fixes include regression tests
  • Chores
  • Documentation changes
  • Features include unit/acceptance tests
  • Refactoring
  • Update dependencies

@RylandBangerter85
Copy link
Author

Is there anything that needs to be changed for this PR? It was submitted almost two weeks ago and I haven't seen anything, so I just wanted to make sure.

defp migration_requires_no_transaction?(file, mod) do
# First check the file content for @disable_ddl_transaction
file_content = File.read!(file)
has_disable_ddl_transaction? = String.contains?(file_content, "@disable_ddl_transaction")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to check both? If the module is compiled we ought to be able to just ask the module and not bother looking at the file, since they could theoretically do Module.put_attribute(__MODULE__, :disable_ddl_transaction, true)

@RylandBangerter85 RylandBangerter85 force-pushed the fix-concurrent-index-multitenancy branch from f433072 to afb3a5c Compare February 23, 2026 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants