Add schema migration safety tests and maintenance operation tests
Summary
This PR adds comprehensive test coverage for schema migration safety guarantees and database maintenance operations (optimize/cleanup). The changes ensure that destructive schema changes are properly rejected while supported operations like renames preserve data correctly.
Key Changes
Schema Migration Safety Tests (schema_apply.rs)
-
Destructive change rejections: Added tests verifying that the following unsupported operations are rejected without advancing the manifest:
- Dropping properties with data (
apply_schema_rejects_dropping_a_property_with_data) - Dropping node types (
apply_schema_rejects_dropping_a_node_type) - Dropping edge types (
apply_schema_rejects_dropping_an_edge_type) - Adding required properties without backfill (
apply_schema_rejects_adding_a_required_property_without_backfill) - Narrowing property types (
plan_schema_for_property_type_narrowing_is_not_supported)
- Dropping properties with data (
-
Supported rename operation: Added test verifying that type and property renames via
@rename_fromare supported and preserve existing rows (apply_schema_renames_node_type_via_rename_from_and_preserves_rows) -
Documentation: Added detailed comments explaining the v1 schema migration contract (additive-only changes with specific exceptions for renames)
Maintenance Operations Tests (maintenance.rs - new file)
-
Optimize operations: Tests for Lance
compact_filesat the graph level- Empty repo optimization returns per-table stats with no changes
- Post-load optimization is idempotent (re-running produces no changes)
-
Cleanup operations: Tests for Lance
cleanup_old_versionswith policy validation- Cleanup without policy options properly errors with descriptive message
keep_versions=1preserves head and maintains table readabilityolder_than=0aggressively cleans while preserving head manifest- Cleanup and optimize can be sequenced successfully
Documentation
- Updated
docs/testing.mdto reflect new test file count (15 → 17 files)
Notable Implementation Details
- All tests use the shared fixture helpers (
init_and_load,count_rows,TEST_SCHEMA,TEST_DATA) - Tests verify both the error messages and the invariant that manifest version doesn't advance on rejection
- Maintenance tests cover both happy paths and edge cases (empty repo, already-optimized state, aggressive policies)
- Tests ensure Lance's head-preservation contract is maintained across cleanup operations
https://claude.ai/code/session_01A8SRthivpSGZy3WRXMkz9j
[!NOTE]
Low Risk
Test-only changes plus a docs update; no production logic is modified, so risk is limited to potential CI flakiness from new integration tests.
Overview
Adds a new maintenance.rs integration test suite that exercises graph-level optimize/cleanup behavior, including empty/idempotent compaction, cleanup policy validation, and ensuring “head” remains readable/writable after aggressive version GC and after a cleanup→optimize sequence.
Expands schema_apply.rs with safety-tier migration tests that assert destructive schema changes are rejected without advancing the manifest (drop property/type/edge, add required property, type narrowing), and adds a positive test that @rename_from type/property renames apply successfully and preserve existing rows. Updates docs/testing.md to reflect the new test files list/count.
Reviewed by Cursor Bugbot for commit 02b72169e3c4fc310974f9943a3bbe6230b3c594. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by cubic
Adds integration tests for schema migration safety and database maintenance (optimize/cleanup).
Covers destructive change rejections without manifest advance, a real @rename_from rename (Person → Human) that preserves rows and emits RenameType, optimize no‑op/idempotency, cleanup policy validation with head preserved, and a cleanup→optimize sequence that preserves rows and remains writable; plus docs updates (count to 17; add validators.rs, maintenance.rs).