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:
parent
a9e82779e7
commit
6f6f1757ea
1 changed files with 3 additions and 0 deletions
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue