diff --git a/priv/repo/migrations/20260325215632_deduplicate_discovery_checks.exs b/priv/repo/migrations/20260325215632_deduplicate_discovery_checks.exs index f1a2a7c6..2298b64e 100644 --- a/priv/repo/migrations/20260325215632_deduplicate_discovery_checks.exs +++ b/priv/repo/migrations/20260325215632_deduplicate_discovery_checks.exs @@ -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",