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
12 lines
594 B
SQL
12 lines
594 B
SQL
-- Backfill existing non-system notes into dirty queue for document generation.
|
|
-- Only seeds notes that don't already have documents and aren't already queued.
|
|
INSERT INTO dirty_sources (source_type, source_id, queued_at)
|
|
SELECT 'note', n.id, CAST(strftime('%s', 'now') AS INTEGER) * 1000
|
|
FROM notes n
|
|
LEFT JOIN documents d ON d.source_type = 'note' AND d.source_id = n.id
|
|
WHERE n.is_system = 0 AND d.id IS NULL
|
|
ON CONFLICT(source_type, source_id) DO NOTHING;
|
|
|
|
INSERT INTO schema_version (version, applied_at, description)
|
|
VALUES (25, strftime('%s', 'now') * 1000, '025_note_dirty_backfill');
|