refactor: centralize schema migration planning#524
Conversation
|
Warning Review limit reached
Your plan currently allows 1 review/hour. Refill in 47 minutes and 58 seconds. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more review capacity refills, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (15)
📝 WalkthroughWalkthroughThis PR consolidates schema migration planning into a centralised shared module. The new ChangesSchema migration planning refactor
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Cairn Quality ReportCommit:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/phlo/schema_registry.py (1)
1-1: ⚡ Quick winRefresh the module docstring after removing compatibility checks.
This module now handles snapshotting/registry concerns only; “detecting breaking changes” suggests functionality that was removed with
check_compatibility(...).🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/phlo/schema_registry.py` at line 1, Update the module docstring to remove the phrase about “detecting breaking changes” and describe the module's current responsibility: snapshotting and registry management of schemas only; reference the removed function check_compatibility(...) in the updated text to clarify that compatibility checking was removed and is no longer provided by this module.src/phlo/helpers/schema.py (1)
1-1: ⚡ Quick winUpdate the module docstring to match the trimmed API.
compare_schemas,suggest_schema_migration, andassert_schema_compatibleare gone, so “comparison helpers” now overstates what this module provides.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/phlo/helpers/schema.py` at line 1, Update the module docstring at the top of the schema module to remove the reference to comparison helpers (the functions compare_schemas, suggest_schema_migration, and assert_schema_compatible have been removed); replace the current string "Normalized schema construction and comparison helpers." with wording that reflects the trimmed API such as "Normalized schema construction helpers." so the docstring accurately describes the remaining functionality.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/phlo/schema_migration/planning.py`:
- Around line 217-244: The _validate_renames logic currently allows
chained/swapped renames by permitting a rename whose new_name already exists in
current_fields when that existing name is also a rename source; change this to
reject such cases and also reject no-op renames where old_name == new_name.
Concretely: inside _validate_renames (symbols: renames, current_fields,
desired_fields, seen_targets, renamed_sources) add an explicit check that raises
SchemaMigrationPlanningError if old_name == new_name, and change the later
validation so that any new_name present in current_fields is invalid (remove the
exception for renamed_sources) — keep the existing checks for empty names,
missing source/target in current/desired, and duplicate targets (seen_targets)
unchanged.
---
Nitpick comments:
In `@src/phlo/helpers/schema.py`:
- Line 1: Update the module docstring at the top of the schema module to remove
the reference to comparison helpers (the functions compare_schemas,
suggest_schema_migration, and assert_schema_compatible have been removed);
replace the current string "Normalized schema construction and comparison
helpers." with wording that reflects the trimmed API such as "Normalized schema
construction helpers." so the docstring accurately describes the remaining
functionality.
In `@src/phlo/schema_registry.py`:
- Line 1: Update the module docstring to remove the phrase about “detecting
breaking changes” and describe the module's current responsibility: snapshotting
and registry management of schemas only; reference the removed function
check_compatibility(...) in the updated text to clarify that compatibility
checking was removed and is no longer provided by this module.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: ab6b3cf2-b5d3-4758-a59e-4e672cbc4eb3
📒 Files selected for processing (15)
packages/phlo-delta/src/phlo_delta/schema_migrator.pypackages/phlo-iceberg/src/phlo_iceberg/schema_migrator.pysrc/phlo/cli/commands/schema_migrate.pysrc/phlo/cli/commands/schema_migrate_contracts.pysrc/phlo/cli/commands/schema_registry_cli.pysrc/phlo/helpers/__init__.pysrc/phlo/helpers/schema.pysrc/phlo/schema_migration/__init__.pysrc/phlo/schema_migration/instructions.pysrc/phlo/schema_migration/planning.pysrc/phlo/schema_registry.pytests/cli/test_cli_schema_migrate.pytests/data/test_schema_migration_planning.pytests/data/test_schema_registry.pytests/unit/helpers/test_helpers_core.py
💤 Files with no reviewable changes (2)
- src/phlo/helpers/init.py
- tests/data/test_schema_registry.py
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: cairn / report
🔇 Additional comments (3)
tests/data/test_schema_migration_planning.py (1)
1-198: LGTM!tests/cli/test_cli_schema_migrate.py (1)
23-23: LGTM!Also applies to: 287-287, 292-526
tests/unit/helpers/test_helpers_core.py (1)
49-49: LGTM!Also applies to: 101-103
0fdd575 to
5da7d5e
Compare
Summary
Centralizes schema migration planning behind the new
phlo.schema_migrationpackage and removes duplicated provider diff logic from the Iceberg and Delta adapters.What changed
--rename old=newflags.schema-migrate diff,plan, andapplyto use one planning path instead of duplicating instruction resolution in each command.apply --dry-runvalidate provider support before printing dry-run output.Validation
uv run pytest tests/data/test_schema_migration_planning.py tests/data/test_schema_migration.py tests/data/test_schema_registry.py tests/data/test_schema_migrate_contracts.py tests/cli/test_cli_schema_migrate.py tests/unit/helpers/test_helpers_core.py packages/phlo-iceberg/tests/test_schema_migrator.py packages/phlo-delta/tests -q->128 passed, 1 deselecteduv run ruff check src/phlo/schema_migration src/phlo/cli/commands/schema_migrate.py src/phlo/cli/commands/schema_migrate_contracts.py packages/phlo-iceberg/src/phlo_iceberg/schema_migrator.py packages/phlo-delta/src/phlo_delta/schema_migrator.py tests/data/test_schema_migration_planning.py tests/cli/test_cli_schema_migrate.pygit diff --checkuv run ty check ...exited 0 with existing warnings in tests around dynamic module attributes, monkeypatched methods, and possibleNoneaccess.