mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-26 12:16:39 +00:00
disable avoid adding group peers multiple times
This commit is contained in:
@@ -15,6 +15,7 @@ import (
|
|||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
"gorm.io/gorm/clause"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetColumnName(db *gorm.DB, column string) string {
|
func GetColumnName(db *gorm.DB, column string) string {
|
||||||
@@ -456,7 +457,9 @@ func MigrateJsonToTable[T any](ctx context.Context, db *gorm.DB, columnName stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, value := range data {
|
for _, value := range data {
|
||||||
if err := tx.Create(
|
if err := tx.Clauses(clause.OnConflict{
|
||||||
|
DoNothing: true, // this needs to be removed when the cleanup is enabled
|
||||||
|
}).Create(
|
||||||
mapperFunc(row["id"].(string), value),
|
mapperFunc(row["id"].(string), value),
|
||||||
).Error; err != nil {
|
).Error; err != nil {
|
||||||
return fmt.Errorf("failed to insert id %v: %w", row["id"], err)
|
return fmt.Errorf("failed to insert id %v: %w", row["id"], err)
|
||||||
|
|||||||
Reference in New Issue
Block a user