From 5028f93f83a2e1eb02966d2d7e9e2a7e4b7d8bf1 Mon Sep 17 00:00:00 2001 From: Kegan Dougal <7190048+kegsay@users.noreply.github.com> Date: Fri, 17 May 2024 15:37:45 +0100 Subject: [PATCH] If there's no updates, don't insert anything --- state/migrations/20240517104423_device_list_table.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/state/migrations/20240517104423_device_list_table.go b/state/migrations/20240517104423_device_list_table.go index 1d427c0..5e6d771 100644 --- a/state/migrations/20240517104423_device_list_table.go +++ b/state/migrations/20240517104423_device_list_table.go @@ -122,6 +122,9 @@ func upDeviceListTable(ctx context.Context, tx *sql.Tx) error { Bucket: state.BucketSent, }) } + if len(deviceListRows) == 0 { + continue + } chunks := sqlutil.Chunkify(5, state.MaxPostgresParameters, state.DeviceListChunker(deviceListRows)) for _, chunk := range chunks { var placeholders []string @@ -143,8 +146,6 @@ func upDeviceListTable(ctx context.Context, tx *sql.Tx) error { ) _, err = tx.ExecContext(ctx, query, vals...) if err != nil { - fmt.Println(query) - fmt.Println(vals...) return fmt.Errorf("failed to bulk insert: %s", err) } }