From cadc09b49373d6ee09b6ba709a29d1cc9da29325 Mon Sep 17 00:00:00 2001 From: henrygd Date: Fri, 14 Mar 2025 23:03:07 -0400 Subject: [PATCH] delete duplicate alerts as part of 0.10.2 migrations --- beszel/migrations/collections_snapshot_0_10_2.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/beszel/migrations/collections_snapshot_0_10_2.go b/beszel/migrations/collections_snapshot_0_10_2.go index a985f12..aecbb8a 100644 --- a/beszel/migrations/collections_snapshot_0_10_2.go +++ b/beszel/migrations/collections_snapshot_0_10_2.go @@ -7,6 +7,17 @@ import ( func init() { m.Register(func(app core.App) error { + // delete duplicate alerts + app.DB().NewQuery(` + DELETE FROM alerts + WHERE rowid NOT IN ( + SELECT MAX(rowid) + FROM alerts + GROUP BY user, system, name + ); + `).Execute() + + // import collections jsonData := `[ { "id": "elngm8x1l60zi2v",