MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / test_migrate_from_v0

Function test_migrate_from_v0

tests/storage_suite/migration_test.rs:544–582  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

542/// migrate from v0 (completely empty database) applies all migrations to latest.
543#[tokio::test]
544async fn test_migrate_from_v0() {
545 let (conn, _db, _dir) = create_raw_db().await;
546
547 // user_version defaults to 0 on a fresh database
548 assert_eq!(get_user_version(&conn).await, 0);
549
550 let migrated = migrate(&conn)
551 .await
552 .expect("migrate from v0 should succeed");
553
554 assert!(
555 migrated,
556 "migrate should return true when migrations were applied"
557 );
558 assert_eq!(get_user_version(&conn).await, 15);
559
560 // All expected tables should exist
561 assert!(table_exists(&conn, "nodes").await);
562 assert!(table_exists(&conn, "edges").await);
563 assert!(table_exists(&conn, "files").await);
564 assert!(table_exists(&conn, "unresolved_refs").await);
565 assert!(table_exists(&conn, "vectors").await);
566 assert!(table_exists(&conn, "metadata").await);
567 assert!(table_exists(&conn, "nodes_fts").await);
568
569 // V3 complexity columns should exist
570 assert!(column_exists(&conn, "nodes", "branches").await);
571 assert!(column_exists(&conn, "nodes", "loops").await);
572 assert!(column_exists(&conn, "nodes", "returns").await);
573 assert!(column_exists(&conn, "nodes", "max_nesting").await);
574
575 // V4 safety columns should exist
576 assert!(column_exists(&conn, "nodes", "unsafe_blocks").await);
577 assert!(column_exists(&conn, "nodes", "unchecked_calls").await);
578 assert!(column_exists(&conn, "nodes", "assertions").await);
579
580 // V5 unique index should exist
581 assert!(index_exists(&conn, "idx_edges_unique").await);
582}
583
584/// migrate from v1 (tables exist, no metadata, no complexity columns) to v5.
585#[tokio::test]

Callers

nothing calls this directly

Calls 2

create_raw_dbFunction · 0.85
migrateFunction · 0.85

Tested by

no test coverage detected