# Migration History

> High-level record of significant schema evolution. Detail lives in `database/migrations/` and `docs/refactor/`.

_Verified against `database/migrations/` (count) and model docblocks on 2026-07-23._

---

## Scale
- **~219 migrations.** The schema has undergone heavy, well-documented churn (model docblocks are unusually detailed about deprecations — a good reference).

## Major migration threads (validated)
- **Name localization (Phase 1–7)** — introduced bilingual `*_ar`/`*_en` name pairs and locale-aware accessors; legacy single `name` column being phased out.
- **Labels architecture v2** — the dynamic `Label` → `LabelOption` classification backbone with dual natural keys for app vs Monday sync.
- **Groups repointing** — pipeline groups mapped to Monday group IDs.
- **Deduplication flips** — evolved from a scoring approach to **merge-on-insert** (canonical row absorbs duplicates; satellite relations removed).
- **OAuth 2.1 server tables** — clients, access/refresh tokens, authorization codes, consents, scopes, audit/anomaly logs, JWT blacklist; plus `GraphOAuthToken`.
- **Managed-agent tables** — ~8 tables (`Agent`, `AgentRun`, `AgentApprovalRequest`, `ExecutionRequest`, `Handoff`, `AgentActionPolicy`, `PolicyRuntimeOverride`, and the single `agent_knowledge_cache`), plus AI task/session/activity tables.

## Refactor notes (historical)
`docs/refactor/columns-to-drop.md`, `columns-to-rename.md`, and `runbook.md` capture a schema-refactor delta and a one-time destructive migration runbook. **The runbook was almost certainly already executed** — treat as historical. Exact applied-state: **Unknown - requires confirmation.**

## Note
This file is a narrative summary, not a per-migration log. For exact ordering, read `database/migrations/` directly.
