Skip to content

Commit

Permalink
If there's no updates, don't insert anything
Browse files Browse the repository at this point in the history
  • Loading branch information
kegsay committed May 17, 2024
1 parent fcd9b49 commit 5028f93
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions state/migrations/20240517104423_device_list_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
}
Expand Down

0 comments on commit 5028f93

Please sign in to comment.