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:
parent
d9f7cd4e56
commit
42fce1b933
1 changed files with 12 additions and 3 deletions
|
|
@ -1,10 +1,19 @@
|
|||
defmodule Aprsme.Repo.Migrations.AddCallsignSearchIndexes do
|
||||
use Ecto.Migration
|
||||
@disable_ddl_transaction true
|
||||
@disable_migration_lock true
|
||||
|
||||
def up do
|
||||
# In test environment, skip index creation to avoid timeout issues
|
||||
# Indexes will be created in production where the table has actual data
|
||||
if Mix.env() != :test do
|
||||
# Check if we're in a test environment by looking at the repo config
|
||||
# In test, the pool is Ecto.Adapters.SQL.Sandbox which doesn't support CONCURRENTLY
|
||||
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
|
||||
# Using text_pattern_ops for LIKE/ILIKE queries via raw SQL
|
||||
execute """
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue