Skip to content

Revert "chore(db): remove deprecated entity schema from memory_links" (#3177) - #3244

Merged
nicoloboschi merged 2 commits into
mainfrom
revert-pr-3177
Aug 7, 2026
Merged

Revert "chore(db): remove deprecated entity schema from memory_links" (#3177)#3244
nicoloboschi merged 2 commits into
mainfrom
revert-pr-3177

Conversation

@nicoloboschi

Copy link
Copy Markdown
Collaborator

Reverts #3177 (squash commit 5f8a030).

Why

Migration c1e7a9d3f5b2 collapses idx_memory_links_unique — which means rebuilding the unique index on memory_links. On large established banks that table (and index) is huge, and even with CONCURRENTLY/ONLINE the rebuild is a long, expensive operation we don't want to impose for what was a pure schema cleanup with no functional benefit.

#3177 was never shipped in a core release (latest is v0.8.6, cut 2026-07-29), so reverting now means released environments never run it.

What this PR does

  • git revert of the squash commit: restores the memory_links entity schema plumbing (MemoryLink.entity_id, write-path code, tests) and deletes migration c1e7a9d3f5b2 and its migration test.
  • Fixes the Alembic chain: f2a6d8c4b1e9 (drop stale global vector index) chained off the deleted revision; it is re-parented onto e4a7c1b9d2f6 (drop access_count). Chain now resolves to the single head b3e8d1c6f4a9 (verified by walking all 94 revisions).

Upgrade path from v0.8.6 is now … → e4a7c1b9d2f6 → f2a6d8c4b1e9 → b3e8d1c6f4a9 — the entity-schema drop is simply gone from the tree, so upgraders never execute it.

Caveat for environments tracking main

Any environment that started the API between #3177's merge (2026-08-04) and this revert has already applied c1e7a9d3f5b2 (migrations run on startup):

  • If its alembic_version has since advanced past it, migrations still resolve, but the schema is missing memory_links.entity_id while the reverted code writes that column — it needs a manual re-add of the entity schema (or a DB reset for dev envs).
  • If its alembic_version is exactly c1e7a9d3f5b2, Alembic will fail with "Can't locate revision" until the version row is stamped to e4a7c1b9d2f6.

This only affects main-trackers from the last 3 days; no released environment is impacted.

Testing

  • tests/test_migration_shape.py + tests/test_link_utils.py pass (215 passed).
  • ./scripts/hooks/lint.sh clean.
  • Alembic script directory resolves to a single head with no dangling revisions.

@nicoloboschi
nicoloboschi merged commit 404fe46 into main Aug 7, 2026
102 of 103 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant