Defense-in-depth: The migration framework already handles missing inserts via INSERT OR REPLACE (db.rs:174), but adding explicit inserts to .sql files ensures consistency and makes migrations self-documenting. Migrations affected: - 022_notes_query_index - 024_note_documents - 025_note_dirty_backfill - 026_scoring_indexes - 027_surgical_sync_runs
24 lines
1.2 KiB
SQL
24 lines
1.2 KiB
SQL
-- Migration 027: Extend sync_runs for surgical sync observability
|
|
-- Adds mode/phase tracking and surgical-specific counters.
|
|
|
|
ALTER TABLE sync_runs ADD COLUMN mode TEXT;
|
|
ALTER TABLE sync_runs ADD COLUMN phase TEXT;
|
|
ALTER TABLE sync_runs ADD COLUMN surgical_iids_json TEXT;
|
|
ALTER TABLE sync_runs ADD COLUMN issues_fetched INTEGER NOT NULL DEFAULT 0;
|
|
ALTER TABLE sync_runs ADD COLUMN mrs_fetched INTEGER NOT NULL DEFAULT 0;
|
|
ALTER TABLE sync_runs ADD COLUMN issues_ingested INTEGER NOT NULL DEFAULT 0;
|
|
ALTER TABLE sync_runs ADD COLUMN mrs_ingested INTEGER NOT NULL DEFAULT 0;
|
|
ALTER TABLE sync_runs ADD COLUMN skipped_stale INTEGER NOT NULL DEFAULT 0;
|
|
ALTER TABLE sync_runs ADD COLUMN docs_regenerated INTEGER NOT NULL DEFAULT 0;
|
|
ALTER TABLE sync_runs ADD COLUMN docs_embedded INTEGER NOT NULL DEFAULT 0;
|
|
ALTER TABLE sync_runs ADD COLUMN warnings_count INTEGER NOT NULL DEFAULT 0;
|
|
ALTER TABLE sync_runs ADD COLUMN cancelled_at INTEGER;
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_sync_runs_mode_started
|
|
ON sync_runs(mode, started_at DESC);
|
|
CREATE INDEX IF NOT EXISTS idx_sync_runs_status_phase_started
|
|
ON sync_runs(status, phase, started_at DESC);
|
|
|
|
INSERT INTO schema_version (version, applied_at, description)
|
|
VALUES (27, strftime('%s', 'now') * 1000, '027_surgical_sync_runs');
|