From 9f0585676bccd6f991f68cf73be9d42e5fbd233c Mon Sep 17 00:00:00 2001 From: Michael Bumann Date: Wed, 10 Jan 2024 10:22:28 +0200 Subject: [PATCH] Create index only if it does not exist otherwise the migration fails --- migrations/202401092201_add_events_id_index.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migrations/202401092201_add_events_id_index.go b/migrations/202401092201_add_events_id_index.go index 7b2ef48e..babb014f 100644 --- a/migrations/202401092201_add_events_id_index.go +++ b/migrations/202401092201_add_events_id_index.go @@ -9,7 +9,7 @@ import ( var _202401092201_add_events_id_index = &gormigrate.Migration{ ID: "202401092201_add_events_id_index", Migrate: func(tx *gorm.DB) error { - return tx.Exec("CREATE INDEX idx_nostr_events_app_id_and_id ON nostr_events(app_id, id)").Error + return tx.Exec("CREATE INDEX IF NOT EXISTS idx_nostr_events_app_id_and_id ON nostr_events(app_id, id)").Error }, Rollback: func(tx *gorm.DB) error { return nil