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)
| 271 | // checkTaskDrift performs the actual drift comparison logic. |
| 272 | // Returns nil if no drift, or an error describing the drift. |
| 273 | func 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 |