Use runtime pool check instead of Mix.env for migration

Mix.env() is not available in production releases, so we need to check
the repo's pool configuration at runtime instead. In test, the pool is
Ecto.Adapters.SQL.Sandbox which doesn't support CONCURRENTLY, so we
skip index creation. In production/dev, indexes are created normally.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Graham McIntire 2025-10-25 16:54:10 -05:00
parent d9f7cd4e56
commit 42fce1b933
No known key found for this signature in database

View file

@ -1,10 +1,19 @@
defmodule Aprsme.Repo.Migrations.AddCallsignSearchIndexes do defmodule Aprsme.Repo.Migrations.AddCallsignSearchIndexes do
use Ecto.Migration use Ecto.Migration
@disable_ddl_transaction true
@disable_migration_lock true
def up do def up do
# In test environment, skip index creation to avoid timeout issues # Check if we're in a test environment by looking at the repo config
# Indexes will be created in production where the table has actual data # In test, the pool is Ecto.Adapters.SQL.Sandbox which doesn't support CONCURRENTLY
if Mix.env() != :test do pool_module = Aprsme.Repo.config()[:pool]
if pool_module == Ecto.Adapters.SQL.Sandbox do
# Test environment - skip index creation to avoid timeout issues
# The test database is empty anyway
:ok
else
# Production/dev environment - create indexes with CONCURRENTLY
# Add index on sender for pattern matching searches # Add index on sender for pattern matching searches
# Using text_pattern_ops for LIKE/ILIKE queries via raw SQL # Using text_pattern_ops for LIKE/ILIKE queries via raw SQL
execute """ execute """