🐛 Trying to fix duplicate key when inserting

This commit is contained in:
LittleSheep 2025-01-26 13:49:52 +08:00
parent b398311bd2
commit f392f12f76
2 changed files with 4 additions and 2 deletions

View File

@ -46,7 +46,8 @@ func adminTriggerScanTask(c *fiber.Ctx) error {
return item.Hash
})
database.C.Clauses(clause.OnConflict{
UpdateAll: true,
Columns: []clause.Column{{Name: "hash"}},
DoUpdates: clause.Assignments(map[string]interface{}{}),
}).Create(&result)
log.Info().Str("source", src.ID).Int("count", len(result)).Msg("Scanned a news sources.")

View File

@ -48,7 +48,8 @@ func ScanNewsSources(eager ...bool) {
return item.Hash
})
database.C.Clauses(clause.OnConflict{
UpdateAll: true,
Columns: []clause.Column{{Name: "hash"}},
DoUpdates: clause.Assignments(map[string]interface{}{}),
}).Create(&result)
log.Info().Str("source", src.ID).Int("count", len(result)).Msg("Scanned a news sources.")