fix(migrations): add schema_version inserts to migrations 022-027
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
This commit is contained in:
@@ -19,3 +19,6 @@ CREATE INDEX IF NOT EXISTS idx_discussions_mr_id ON discussions(merge_request_id
|
|||||||
-- Immutable author identity column (GitLab numeric user ID)
|
-- Immutable author identity column (GitLab numeric user ID)
|
||||||
ALTER TABLE notes ADD COLUMN author_id INTEGER;
|
ALTER TABLE notes ADD COLUMN author_id INTEGER;
|
||||||
CREATE INDEX IF NOT EXISTS idx_notes_author_id ON notes(author_id) WHERE author_id IS NOT NULL;
|
CREATE INDEX IF NOT EXISTS idx_notes_author_id ON notes(author_id) WHERE author_id IS NOT NULL;
|
||||||
|
|
||||||
|
INSERT INTO schema_version (version, applied_at, description)
|
||||||
|
VALUES (22, strftime('%s', 'now') * 1000, '022_notes_query_index');
|
||||||
|
|||||||
@@ -151,3 +151,6 @@ END;
|
|||||||
|
|
||||||
DROP TABLE IF EXISTS _doc_labels_backup;
|
DROP TABLE IF EXISTS _doc_labels_backup;
|
||||||
DROP TABLE IF EXISTS _doc_paths_backup;
|
DROP TABLE IF EXISTS _doc_paths_backup;
|
||||||
|
|
||||||
|
INSERT INTO schema_version (version, applied_at, description)
|
||||||
|
VALUES (24, strftime('%s', 'now') * 1000, '024_note_documents');
|
||||||
|
|||||||
@@ -6,3 +6,6 @@ FROM notes n
|
|||||||
LEFT JOIN documents d ON d.source_type = 'note' AND d.source_id = n.id
|
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
|
WHERE n.is_system = 0 AND d.id IS NULL
|
||||||
ON CONFLICT(source_type, source_id) DO NOTHING;
|
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');
|
||||||
|
|||||||
@@ -18,3 +18,6 @@ CREATE INDEX IF NOT EXISTS idx_notes_diffnote_discussion_author
|
|||||||
CREATE INDEX IF NOT EXISTS idx_notes_old_path_project_created
|
CREATE INDEX IF NOT EXISTS idx_notes_old_path_project_created
|
||||||
ON notes(position_old_path, project_id, created_at)
|
ON notes(position_old_path, project_id, created_at)
|
||||||
WHERE note_type = 'DiffNote' AND is_system = 0 AND position_old_path IS NOT NULL;
|
WHERE note_type = 'DiffNote' AND is_system = 0 AND position_old_path IS NOT NULL;
|
||||||
|
|
||||||
|
INSERT INTO schema_version (version, applied_at, description)
|
||||||
|
VALUES (26, strftime('%s', 'now') * 1000, '026_scoring_indexes');
|
||||||
|
|||||||
@@ -18,3 +18,6 @@ CREATE INDEX IF NOT EXISTS idx_sync_runs_mode_started
|
|||||||
ON sync_runs(mode, started_at DESC);
|
ON sync_runs(mode, started_at DESC);
|
||||||
CREATE INDEX IF NOT EXISTS idx_sync_runs_status_phase_started
|
CREATE INDEX IF NOT EXISTS idx_sync_runs_status_phase_started
|
||||||
ON sync_runs(status, phase, started_at DESC);
|
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');
|
||||||
|
|||||||
Reference in New Issue
Block a user