Skip to content

Commit 043078a

Browse files
committed
use clause.Insert to handle conflicts
1 parent e960399 commit 043078a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

indexer/database.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func (ci *BlockIndexer) saveData(
2626
) error {
2727
return ci.db.Transaction(func(tx *gorm.DB) error {
2828
if len(data.Blocks) != 0 {
29-
err := tx.Clauses(clause.OnConflict{DoNothing: true}).
29+
err := tx.Clauses(clause.Insert{Modifier: "IGNORE"}).
3030
CreateInBatches(data.Blocks, database.DBTransactionBatchesSize).
3131
Error
3232
if err != nil {
@@ -36,7 +36,7 @@ func (ci *BlockIndexer) saveData(
3636

3737
if len(data.Transactions) != 0 {
3838
// insert transactions in the database, if an entry already exists, do nothing
39-
err := tx.Clauses(clause.OnConflict{DoNothing: true}).
39+
err := tx.Clauses(clause.Insert{Modifier: "IGNORE"}).
4040
CreateInBatches(data.Transactions, database.DBTransactionBatchesSize).
4141
Error
4242
if err != nil {
@@ -46,7 +46,7 @@ func (ci *BlockIndexer) saveData(
4646

4747
if len(data.Logs) != 0 {
4848
// insert logs in the database, if an entry already exists, do nothing
49-
err := tx.Clauses(clause.OnConflict{DoNothing: true}).
49+
err := tx.Clauses(clause.Insert{Modifier: "IGNORE"}).
5050
CreateInBatches(data.Logs, database.DBTransactionBatchesSize).
5151
Error
5252
if err != nil {

0 commit comments

Comments
 (0)