Skip to content

Commit 422400a

Browse files
committed
skip updating node if it has no interface
1 parent 8e1fd2c commit 422400a

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

node-registrar/pkg/db/migrate.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,18 @@ func (db Database) migrateNodes() error {
6969
interfaces = append(interfaces, newInterface)
7070
}
7171

72-
// Update only the interfaces field
73-
if err := tx.Model(&Node{}).
74-
Where("node_id = ?", node.NodeID).
75-
Update("interfaces", interfaces).Error; err != nil {
76-
return err // This will roll back the entire transaction
72+
// skip the node if it has no interfaces
73+
if len(interfaces) != 0 {
74+
// Update only the interfaces field
75+
if err := tx.Model(&Node{}).
76+
Where("node_id = ?", node.NodeID).
77+
Update("interfaces", interfaces).Error; err != nil {
78+
return err // This will roll back the entire transaction
79+
}
80+
81+
log.Info().Uint64("node_id", node.NodeID).Msg("Migration: updating node")
7782
}
83+
7884
}
7985

8086
return nil

0 commit comments

Comments
 (0)