CloudMigrations: Omit autoincremented id for alert snapshots (#106598)

If you tried to migrate alerts from two differente sources/on-prem instances,
the autoincremented numeric id would be the same, and since we were creating
the resource in cloud with that same id (the API accepts it), it would
return an error "conflicting alert rule found" because that id is the primary key on the table.

We simply omit the numeric id now and let the API for the cloud instance generate it.
This commit is contained in:
Matheus Macabu
2025-06-12 15:38:21 +02:00
committed by GitHub
parent d041ae8e73
commit a1f2693fd8
@@ -135,7 +135,6 @@ type alertRule struct {
Title string `json:"title"`
ExecErrState string `json:"execErrState"`
Data []definitions.AlertQuery `json:"data"`
ID int64 `json:"id"`
For model.Duration `json:"for"`
OrgID int64 `json:"orgID"`
IsPaused bool `json:"isPaused"`
@@ -158,7 +157,6 @@ func (s *Service) getAlertRules(ctx context.Context, signedInUser *user.SignedIn
}
provisionedAlertRules = append(provisionedAlertRules, alertRule{
ID: rule.ID,
UID: rule.UID,
OrgID: rule.OrgID,
FolderUID: rule.NamespaceUID,
@@ -208,7 +206,6 @@ func (s *Service) getAlertRuleGroups(ctx context.Context, signedInUser *user.Sig
}
provisionedAlertRules = append(provisionedAlertRules, alertRule{
ID: rule.ID,
UID: rule.UID,
OrgID: rule.OrgID,
FolderUID: rule.NamespaceUID,