Goal
Fix migration number collisions in the
migrations/ directory and ensure the
migration_history table is consistent. Remove duplicate copies of migration files.
Acceptance Criteria
☐ No two migration files share the same numeric prefix (e.g., 002_.py vs 002_.py)
☐ migration_history table has no duplicate version entries
☐ Duplicate scripts/archive/ copies of migration files are removed or clearly documented
☐ No stale migration files remain that should have been deleted
Approach
Audit migration numbering collisions
- List all numbered migrations in
migrations/ (e.g.,
002_*)
- Identify any numeric collisions (two files with same prefix)
- Fix by renaming one of the colliding migrations to the next available number
Audit duplicate migration files
- Compare files like
migrations/064_add_backup_log_table.sql vs
migrations/add_backup_log_table.sql - Determine which is the authoritative version
- Remove the duplicate/stale copy
Check migration_history consistency
- Query
migration_history table for duplicate
version entries
- Verify all applied migrations correspond to existing migration files
Clean up scripts/archive/ duplicates
- Check
scripts/archive/versioned_migrations/ for migration files
- Remove any that are exact duplicates of files in
migrations/Work Log
2026-04-17 07:30 PT — Slot minimax:63
- Investigating migration numbering issues
- Found collision candidates:
002_add_resource_tracking.py and migrations/add_resource_tracking.sql (different content, same intent)
- Found duplicate:
064_add_backup_log_table.sql and add_backup_log_table.sql
- Creating spec file
2026-04-17 08:15 PT — Slot minimax:63
- Audit complete: 6 pairs of duplicate numbers found (011, 033, 042, 048, 084, 097)
- Renamed collision files to unique numbers:
- 011_idea_sparks.sql → 018_idea_sparks.sql
- 033_crosslink_wiki_hypotheses.py → 019_crosslink_wiki_hypotheses.py
- 042_add_missing_columns_to_challenges_table.py → 020_add_missing_columns_to_challenges_table.py
- 048_add_wiki_pages_kg_node_id_index.sql → 021_add_wiki_pages_kg_node_id_index.sql
- 084_fix_paper_figures_schema.sql → 022_fix_paper_figures_schema.sql
- 097_edges_ci_indexes.py → 023_edges_ci_indexes.py
- Removed 5 duplicate unnumbered migration files (already had numbered versions):
- add_backup_log_table.sql
- add_resource_tracking.sql
- add_notebooks_table.py
- add_failure_reason.py
- crosslink_wiki_hypotheses.py
- Verified no more duplicate numeric prefixes in migrations/
- scripts/archive/versioned_migrations/ only contains crosslink_wiki_hypotheses_v2.py (not a duplicate)
- migration_history table: empty but properly schema'd; legacy entries use legacy_* versioning