Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,7 @@ func init() {
}

func Up_20251015103505(tx *sql.Tx) error {
var minID, maxID sql.NullInt64
err := tx.QueryRow(`
SELECT MIN(id), MAX(id)
FROM software
WHERE source = 'apps'
AND bundle_identifier IS NOT NULL
AND bundle_identifier != ''
`).Scan(&minID, &maxID)
if err != nil {
return fmt.Errorf("getting ID range: %w", err)
}

if !minID.Valid || !maxID.Valid {
return nil
}

const batchSize = 10000
for startID := minID.Int64; startID <= maxID.Int64; startID += batchSize {
endID := startID + batchSize - 1
if endID > maxID.Int64 {
endID = maxID.Int64
}

softwareStmt := `
softwareStmt := `
UPDATE software SET
checksum = UNHEX(
MD5(
Expand All @@ -54,12 +31,10 @@ func Up_20251015103505(tx *sql.Tx) error {
WHERE source = 'apps'
AND bundle_identifier IS NOT NULL
AND bundle_identifier != ''
AND id >= ? AND id <= ?
`
_, err = tx.Exec(softwareStmt, startID, endID)
if err != nil {
return fmt.Errorf("updating software checksums (batch %d-%d): %w", startID, endID, err)
}
_, err := tx.Exec(softwareStmt)
if err != nil {
return fmt.Errorf("updating software checksums %w", err)
}

return nil
Expand Down
Loading