Skip to content

fix(data-connector): scope startup migrations to core history - #1347

Merged
slin1237 merged 2 commits into
mainfrom
fix/history-storage-core-migrations
Apr 23, 2026
Merged

slin1237 merged 2 commits into
mainfrom
fix/history-storage-core-migrations

Conversation

@slin1237

@slin1237 slin1237 commented Apr 23, 2026 •

Copy link
Copy Markdown
Member

Summary

  • scope normal Oracle/Postgres history-backend startup migrations to the core history schema only
  • stop requiring optional skills and background tables for customer-managed history schemas
  • align the Flyway Oracle schema pin with the core history migration version and document the distinction

Testing

  • cargo +nightly fmt --all --check
  • cargo test -p data-connector
  • cargo clippy -p data-connector --all-targets --all-features -- -D warnings

Summary by CodeRabbit

  • Bug Fixes

    • Migration version 3 applied to remove redundant response schema columns and align history migrations.
  • Documentation

    • Clarified README guidance on core history migration scope and renamed section to “Current core history migrations”.
  • Refactor

    • Oracle and Postgres now run a focused set of history migrations.
  • Tests

    • Added checks ensuring history migration sets contain only versions 1–3.
  • Chores

    • Updated schema pinning to version 3.

Signed-off-by: Simo Lin <linsimo.mark@gmail.com>
@coderabbitai

coderabbitai Bot commented Apr 23, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The PR extracts "history-only" migration arrays (versions 1–3) for Oracle and Postgres, switches store startup to run those history migrations, updates Flyway schema pin to version 3, and clarifies README migration docs describing the core history migration scope (conversations, items, responses).

Changes

Cohort / File(s) Summary
Documentation
crates/data_connector/README.md
Clarifies that normal SQL history backends only enforce core history migrations for conversations, conversation items, and responses; renames section to "Current core history migrations" and documents new core migration v3 removing redundant response columns.
Migration Constants
crates/data_connector/src/oracle_migrations.rs, crates/data_connector/src/postgres_migrations.rs
Introduces named Migration constants and new pub(crate) ORACLE_HISTORY_MIGRATIONS / POSTGRES_HISTORY_MIGRATIONS arrays containing only migrations v1–v3; adds unit tests asserting versions [1,2,3].
Store Startup Logic
crates/data_connector/src/oracle.rs, crates/data_connector/src/postgres.rs
Swap migration inputs: stores now call run_*_migrations with the *_HISTORY_MIGRATIONS arrays instead of the full *_MIGRATIONS.
Flyway Configuration
scripts/oracle_flyway/schema-config.yaml
Pins Flyway schema version from 11 → 3 and updates surrounding comments to reflect the core-history ownership boundary.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • CatherineSue
  • key4ng
  • zhaowenzi
  • gongwei-130
  • XinyueZhang369
  • zhoug9127

Poem

🐰 Hopping through migrations with careful delight,

Core history trimmed to the first three tonight,
Responses lightened, redundant bits drop,
Stores start up tidier — hop, hop, hop! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the primary change: scoping startup migrations to core history, which is reflected across all modified files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/history-storage-core-migrations

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the database migration logic to distinguish between core history migrations and full subsystem schemas. It introduces specific history migration arrays for Oracle and Postgres, updates the respective stores to use these core migrations, and adjusts documentation and Flyway configurations to reflect this change. The review feedback highlights a maintenance risk due to code duplication between the new history migration arrays and the existing full migration lists, suggesting the use of shared constants to ensure consistency.

Comment thread crates/data_connector/src/oracle_migrations.rs Outdated
Comment thread crates/data_connector/src/postgres_migrations.rs Outdated
@github-actions github-actions Bot added documentation Improvements or additions to documentation data-connector Data connector crate changes labels Apr 23, 2026

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean, well-scoped change. Verified migration runner logic handles all deployment scenarios safely (existing v11 deployments, fresh installs, Flyway-managed schemas). No production callers of the full migration arrays remain — dead-code suppression is correctly gated to non-test builds. LGTM.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/data_connector/src/oracle_migrations.rs`:
- Around line 474-481: The test only checks migration.version; extend it to
assert that each ORACLE_HISTORY_MIGRATIONS entry also has the expected
description string and the expected up function pointer to avoid registry drift:
for each migration in ORACLE_HISTORY_MIGRATIONS (use migration.version to
index), assert migration.description equals the canonical description for that
version and assert the migration.up function pointer equals the canonical up
function (compare function pointers with pointer equality, e.g., casting to
fn(...) or using std::ptr::eq) so the test verifies (version, description, up)
match the authoritative registry.

In `@crates/data_connector/src/postgres_migrations.rs`:
- Around line 419-426: The test
postgres_history_migrations_cover_only_core_history_schema only checks versions
and can miss mismatches in description or the up migration mapping; enhance it
to compare the POSTGRES_HISTORY_MIGRATIONS slice against the prefix of the full
POSTGRES_MIGRATIONS registry by validating that for each index i the version,
description and up handler correspond (e.g., migration.version ==
POSTGRES_MIGRATIONS[i].version, migration.description ==
POSTGRES_MIGRATIONS[i].description, and the up functions map to the same
implementation) so any accidental drift between the history subset and the full
registry is detected.
🪄 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: dabaf6ee-61d4-498b-8336-786c72a58d31

📥 Commits

Reviewing files that changed from the base of the PR and between 0c1fffa and b6f8c7b.

📒 Files selected for processing (6)
  • crates/data_connector/README.md
  • crates/data_connector/src/oracle.rs
  • crates/data_connector/src/oracle_migrations.rs
  • crates/data_connector/src/postgres.rs
  • crates/data_connector/src/postgres_migrations.rs
  • scripts/oracle_flyway/schema-config.yaml

Comment thread crates/data_connector/src/oracle_migrations.rs
Comment thread crates/data_connector/src/postgres_migrations.rs
Signed-off-by: Simo Lin <linsimo.mark@gmail.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
crates/data_connector/src/postgres_migrations.rs (1)

415-421: 🧹 Nitpick | 🔵 Trivial

Harden the history drift guard test beyond version-only checks

Line 415 currently validates only version numbers. It should also assert description and up handler parity against the full registry prefix, so silent drift is caught.

♻️ Proposed test hardening
 #[test]
 fn postgres_history_migrations_cover_only_core_history_schema() {
     let versions: Vec<u32> = POSTGRES_HISTORY_MIGRATIONS
         .iter()
         .map(|migration| migration.version)
         .collect();
     assert_eq!(versions, vec![1, 2, 3]);
+
+    for (history, full) in POSTGRES_HISTORY_MIGRATIONS
+        .iter()
+        .zip(POSTGRES_MIGRATIONS.iter())
+    {
+        assert_eq!(history.version, full.version);
+        assert_eq!(history.description, full.description);
+        assert_eq!(history.up as usize, full.up as usize);
+    }
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/data_connector/src/postgres_migrations.rs` around lines 415 - 421, The
test postgres_history_migrations_cover_only_core_history_schema currently only
compares version numbers; update it to also verify description and the up
handler match the canonical registry entries: iterate
POSTGRES_HISTORY_MIGRATIONS and for each index look up the corresponding
registry migration (e.g., CORE_HISTORY_SCHEMA_MIGRATIONS or the intended prefix
list), assert migration.description == registry.description, and assert the up
handlers are the same (compare function pointers with std::ptr::eq or otherwise
compare an identifiable property of the up handler exposed by the migration
struct). This ensures silent drift in description or up logic is detected in
addition to version mismatches.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@crates/data_connector/src/postgres_migrations.rs`:
- Around line 415-421: The test
postgres_history_migrations_cover_only_core_history_schema currently only
compares version numbers; update it to also verify description and the up
handler match the canonical registry entries: iterate
POSTGRES_HISTORY_MIGRATIONS and for each index look up the corresponding
registry migration (e.g., CORE_HISTORY_SCHEMA_MIGRATIONS or the intended prefix
list), assert migration.description == registry.description, and assert the up
handlers are the same (compare function pointers with std::ptr::eq or otherwise
compare an identifiable property of the up handler exposed by the migration
struct). This ensures silent drift in description or up logic is detected in
addition to version mismatches.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 93c929e7-1ce4-43c7-87c2-fef50dabcd0d

📥 Commits

Reviewing files that changed from the base of the PR and between b6f8c7b and 6e3805d.

📒 Files selected for processing (2)
  • crates/data_connector/src/oracle_migrations.rs
  • crates/data_connector/src/postgres_migrations.rs

@slin1237
slin1237 merged commit f394f60 into main Apr 23, 2026
34 checks passed
@slin1237
slin1237 deleted the fix/history-storage-core-migrations branch April 23, 2026 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data-connector Data connector crate changes documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant