try to fix initial db migration
This commit is contained in:
parent
1a52bf4baf
commit
952cd40efe
2 changed files with 23 additions and 1 deletions
|
|
@ -5,8 +5,9 @@ defmodule Aprsme.Repo.Migrations.AddCountOptimizationIndex do
|
|||
def up do
|
||||
# Add a partial index on id that will be used for COUNT(*) queries
|
||||
# This creates a small, fast index that PostgreSQL can use for counting
|
||||
# Skip if already exists (from OptimizeInitialIndexCreation migration)
|
||||
execute """
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS packets_count_idx
|
||||
CREATE INDEX IF NOT EXISTS packets_count_idx
|
||||
ON packets (id)
|
||||
WHERE id IS NOT NULL
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
defmodule Aprsme.Repo.Migrations.OptimizeInitialIndexCreation do
|
||||
use Ecto.Migration
|
||||
@disable_ddl_transaction true
|
||||
|
||||
def up do
|
||||
# Drop and recreate the count optimization index more efficiently
|
||||
execute "DROP INDEX IF EXISTS packets_count_idx"
|
||||
|
||||
# Use a simpler approach - just create the index normally for initial setup
|
||||
# The CONCURRENTLY option is mainly useful in production with live data
|
||||
execute """
|
||||
CREATE INDEX packets_count_idx
|
||||
ON packets (id)
|
||||
WHERE id IS NOT NULL
|
||||
"""
|
||||
end
|
||||
|
||||
def down do
|
||||
execute "DROP INDEX IF EXISTS packets_count_idx"
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Reference in a new issue