This directory contains SQL migrations for the Forge storage schema. The canonical, ordered registration of every migration (and the runtime logic that decides whether each one needs to run) lives in index.ts; this README intentionally avoids duplicating that list so it cannot go stale.
- Scalar fields → columns: When a field becomes frequently accessed or filtered, promote it from JSON blobs to a dedicated column.
- No new JSON blob columns: New tables should have explicit columns for queryable fields. JSON is only used for opaque payloads that are never filtered (e.g.,
dataintui_preferences). - Add fields when needed, not speculatively: Add columns only when a use case requires them. Avoid preemptive denormalization.
- Foreign keys with cascade: Use FK constraints with
ON DELETE CASCADEto ensure cleanup propagates correctly. - Indexes for query patterns: Add indexes matching actual query patterns (loop-scoped, status-scoped, etc.).
Migrations are numbered three-digit SQL files, applied in lexicographic order. New migrations append at the next free number. To check the current head, list files in this directory or read MIGRATIONS in index.ts.
- Create
NNN_short_name.sqlin this directory with the schema change. - Append a new entry to the
MIGRATIONSarray inindex.tswith a matching id, description, and runner. - The runner is expected to be idempotent (check columns/tables before applying) so re-runs are safe.
- Update any affected repository in
src/storage/repos/and add a test if behavior changes.