fix: handle existing index in deduplicate_discovery_checks migration (#179)

- Drop index if exists before creating to handle manual creation
- Prevents duplicate_table error when index was created manually

Reviewed-on: graham/towerops-web#179
This commit is contained in:
Graham McIntire 2026-03-26 11:01:53 -05:00 committed by graham
parent a9e82779e7
commit 6f6f1757ea

View file

@ -33,6 +33,9 @@ defmodule Towerops.Repo.Migrations.DeduplicateDiscoveryChecks do
# Prevent future duplicates for auto-discovered checks.
# Use concurrently: true to avoid locking table during index creation.
# Drop first if it exists (may have been created manually)
execute("DROP INDEX IF EXISTS checks_device_type_source_unique_index")
create(
unique_index(:checks, [:device_id, :check_type, :source_id],
where: "source_type = 'auto_discovery' AND source_id IS NOT NULL",