max / goingson
| 1 | -- Dormancy: record when a project entered its current lifecycle status. |
| 2 | -- |
| 3 | -- The painhours score is driven by age, and age only stops accruing when the |
| 4 | -- caller freezes its anchor. Until now the only thing that froze it was the |
| 5 | -- problem's own triage state, so a problem in an Archived or OnHold project |
| 6 | -- kept climbing toward Critical while nobody was working on that project. The |
| 7 | -- anchor this column supplies is what stops that: a problem whose project is |
| 8 | -- not Active ages to the instant the project went dormant, not to now. |
| 9 | -- |
| 10 | -- Every row is backfilled to the migration instant rather than to created_at. |
| 11 | -- The true transition instants were never recorded and are unrecoverable, and |
| 12 | -- today is the honest floor: it claims only "this status has held since at |
| 13 | -- least now", which is true of every row. Backfilling to created_at would |
| 14 | -- instead assert that every project has always been in its current status, |
| 15 | -- which is false for exactly the rows that matter here. |
| 16 | -- |
| 17 | -- Nullable because SQLite cannot ADD COLUMN with a non-constant DEFAULT. The |
| 18 | -- UPDATE below leaves no NULLs behind; the model still falls back to |
| 19 | -- created_at for a row arriving from an older backup. |
| 20 | |
| 21 | projects ADD COLUMN status_changed_at TEXT; |
| 22 | |
| 23 | UPDATE projects SET status_changed_at = datetime('now'); |
| 24 |