MCPcopy Create free account
hub / github.com/bytebase/bytebase / checkTaskDrift

Function checkTaskDrift

backend/runner/taskrun/running_scheduler.go:273–285  ·  view source on GitHub ↗

checkTaskDrift performs the actual drift comparison logic. Returns nil if no drift, or an error describing the drift.

(task *store.TaskMessage, database *store.DatabaseMessage, plan *store.PlanMessage)

Source from the content-addressed store, hash-verified

271// checkTaskDrift performs the actual drift comparison logic.
272// Returns nil if no drift, or an error describing the drift.
273func checkTaskDrift(task *store.TaskMessage, database *store.DatabaseMessage, plan *store.PlanMessage) error {
274 // Check project drift.
275 if database.ProjectID != plan.ProjectID {
276 return errors.Errorf("target database belongs to project %q, but plan belongs to project %q", database.ProjectID, plan.ProjectID)
277 }
278
279 // Check environment drift.
280 if task.Environment != "" && database.EffectiveEnvironmentID != nil && *database.EffectiveEnvironmentID != task.Environment {
281 return errors.Errorf("target database is in environment %q, but task expected environment %q", *database.EffectiveEnvironmentID, task.Environment)
282 }
283
284 return nil
285}
286
287// isSequentialTask returns whether the task should be executed sequentially.
288// Only release-based DATABASE_MIGRATE tasks are sequential to ensure ordered

Callers 2

TestCheckTaskDriftFunction · 0.85
validateTaskFreshnessMethod · 0.85

Calls 1

ErrorfMethod · 0.80

Tested by 1

TestCheckTaskDriftFunction · 0.68