SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
fix: use first org in agent migration (#8269)
Nityananda Gohain385ee268e301
diff --git a/pkg/sqlmigration/041_update_agents.go b/pkg/sqlmigration/041_update_agents.goindex 3652929c15..5b7993819d 100644--- a/pkg/sqlmigration/041_update_agents.go+++ b/pkg/sqlmigration/041_update_agents.go@@ -5,7 +5,6 @@ import ("database/sql""time"- "github.com/SigNoz/signoz/pkg/errors""github.com/SigNoz/signoz/pkg/factory""github.com/SigNoz/signoz/pkg/sqlstore""github.com/SigNoz/signoz/pkg/types"@@ -131,15 +130,17 @@ func (migration *updateAgents) Up(ctx context.Context, db *bun.DB) error {_ = tx.Rollback()}()- // get all org ids- var orgIDs []string- if err := tx.NewSelect().Model(new(types.Organization)).Column("id").Scan(ctx, &orgIDs); err != nil {- return err- }-- // there are multiple orgs, so we don't need to update the agents table- if len(orgIDs) > 1 {- return errors.Newf(errors.TypeInternal, errors.CodeInternal, "multiple orgs found: %v", orgIDs)+ var orgID string+ err = tx.+ NewSelect().+ ColumnExpr("id").+ Table("organizations").+ Limit(1).+ Scan(ctx, &orgID)+ if err != nil {+ if err != sql.ErrNoRows {+ return err+ }}err = migration.@@ -157,7 +158,7 @@ func (migration *updateAgents) Up(ctx context.Context, db *bun.DB) error {if err == nil && len(existingAgents) > 0 {newAgents, err := migration.- CopyOldAgentToNewAgent(ctx, tx, existingAgents, orgIDs[0])+ CopyOldAgentToNewAgent(ctx, tx, existingAgents, orgID)if err != nil {return err}@@ -190,7 +191,7 @@ func (migration *updateAgents) Up(ctx context.Context, db *bun.DB) error {if err == nil && len(existingAgentConfigVersions) > 0 {newAgentConfigVersions, err := migration.- CopyOldAgentConfigVersionToNewAgentConfigVersion(ctx, tx, existingAgentConfigVersions, orgIDs[0])+ CopyOldAgentConfigVersionToNewAgentConfigVersion(ctx, tx, existingAgentConfigVersions, orgID)if err != nil {return err}@@ -223,7 +224,7 @@ func (migration *updateAgents) Up(ctx context.Context, db *bun.DB) error {if err == nil && len(existingAgentConfigElements) > 0 {newAgentConfigElements, err := migration.- CopyOldAgentConfigElementToNewAgentConfigElement(ctx, tx, existingAgentConfigElements, orgIDs[0])+ CopyOldAgentConfigElementToNewAgentConfigElement(ctx, tx, existingAgentConfigElements, orgID)if err != nil {return err}