From 37b39c447fc8e6954b3602c09b57195da2be82be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Wysoki=C5=84ski?= Date: Tue, 2 Apr 2024 06:54:00 +0200 Subject: [PATCH] fix: couldn't delete player snapshots - query timeout --- ...240402044947_player_snapshots_new_index.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 internal/bun/migrations/20240402044947_player_snapshots_new_index.go diff --git a/internal/bun/migrations/20240402044947_player_snapshots_new_index.go b/internal/bun/migrations/20240402044947_player_snapshots_new_index.go new file mode 100644 index 0000000..1d6f934 --- /dev/null +++ b/internal/bun/migrations/20240402044947_player_snapshots_new_index.go @@ -0,0 +1,19 @@ +package migrations + +import ( + "context" + + "github.com/uptrace/bun" +) + +func init() { + migrations.MustRegister(func(ctx context.Context, db *bun.DB) error { + // CREATE INDEX CONCURRENTLY IF NOT EXISTS player_snapshots_server_key_date_idx ON player_snapshots(server_key, date); + _, err := db.ExecContext(ctx, "CREATE INDEX CONCURRENTLY IF NOT EXISTS"+ + " player_snapshots_server_key_date_idx ON player_snapshots(server_key, date);") + return err + }, func(ctx context.Context, db *bun.DB) error { + _, err := db.ExecContext(ctx, "DROP INDEX CONCURRENTLY IF EXISTS player_snapshots_server_key_date_idx;") + return err + }) +}