Skip to content

fix(mental-models): widen the columns that reference mental_models.id (#5788) - #5793

Merged
nicoloboschi merged 1 commit into
mainfrom
fix/5788-mental-model-id-text
Oct 20, 2026
Merged

nicoloboschi merged 1 commit into
mainfrom
fix/5788-mental-model-id-text

Conversation

@nicoloboschi

Copy link
Copy Markdown
Collaborator

Closes #5788

Problem: mental_models.id is TEXT on PostgreSQL, but mental_model_history.mental_model_id and knowledge_pages.mental_model_id were still VARCHAR(64). A mental model with an id over 64 chars could be created, but every refresh failed on the history insert (value too long for type character varying(64)), and the failure record failed the same way. Oracle had the same gap on knowledge_pages.mental_model_id (VARCHAR2(64) vs VARCHAR2(256)).

Fix:

  • New migration f2a9c4e7b1d3 widens both columns on PG to TEXT (binary-coercible, no rewrite) and knowledge_pages.mental_model_id on Oracle to VARCHAR2(256). Downgrade is a no-op (narrowing could truncate real ids).
  • The original CREATE TABLE DDL in a7b8c9d0e1f2 and a9b8c7d6e5f4 now uses the wide type, so fresh installs get it directly.

Test: tests/test_migration_mental_model_id_text.py narrows both columns back to VARCHAR(64), runs the repair, and writes a mental model, history row and knowledge page with an 87-char id.

…#5788)

mental_model_history.mental_model_id and knowledge_pages.mental_model_id
were VARCHAR(64) on PostgreSQL (knowledge_pages VARCHAR2(64) on Oracle)
while mental_models.id is TEXT / VARCHAR2(256). A mental model with an id
over 64 chars could be created but every refresh failed on the history
insert.

- new migration f2a9c4e7b1d3 widens both columns (PG: TEXT, Oracle:
  knowledge_pages to VARCHAR2(256))
- fix the CREATE TABLE DDL in a7b8c9d0e1f2 and a9b8c7d6e5f4 for fresh installs
- regression test narrows the columns, runs the repair, writes an 87-char id

Closes #5788
@nicoloboschi
nicoloboschi merged commit a806f6e into main Oct 20, 2026
116 of 117 checks passed
@nicoloboschi
nicoloboschi deleted the fix/5788-mental-model-id-text branch October 20, 2026 08:16
@nicoloboschi nicoloboschi mentioned this pull request Nov 3, 2026
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.

mental_model_history.mental_model_id is still VARCHAR(64) on PostgreSQL, so refresh fails for mental model ids over 64 chars

1 participant