From dfb89e841c965452e876a67edcbccb5dddb30f88 Mon Sep 17 00:00:00 2001 From: Paul Hernandez <60959+phernandez@users.noreply.github.com> Date: Wed, 11 Feb 2026 22:24:51 -0600 Subject: [PATCH] fix: use VIRTUAL instead of STORED columns in SQLite migration (#562) Signed-off-by: phernandez Co-authored-by: Claude Opus 4.6 --- .../d7e8f9a0b1c2_add_structured_metadata_indexes.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/basic_memory/alembic/versions/d7e8f9a0b1c2_add_structured_metadata_indexes.py b/src/basic_memory/alembic/versions/d7e8f9a0b1c2_add_structured_metadata_indexes.py index 21131595..bc56b21c 100644 --- a/src/basic_memory/alembic/versions/d7e8f9a0b1c2_add_structured_metadata_indexes.py +++ b/src/basic_memory/alembic/versions/d7e8f9a0b1c2_add_structured_metadata_indexes.py @@ -94,13 +94,15 @@ def upgrade() -> None: return # SQLite: add generated columns for common frontmatter fields + # Constraint: SQLite ALTER TABLE ADD COLUMN only supports VIRTUAL generated columns, + # not STORED. json_extract is deterministic so VIRTUAL columns can still be indexed. if not column_exists(connection, "entity", "tags_json"): op.add_column( "entity", sa.Column( "tags_json", sa.Text(), - sa.Computed("json_extract(entity_metadata, '$.tags')", persisted=True), + sa.Computed("json_extract(entity_metadata, '$.tags')", persisted=False), ), ) if not column_exists(connection, "entity", "frontmatter_status"): @@ -109,7 +111,7 @@ def upgrade() -> None: sa.Column( "frontmatter_status", sa.Text(), - sa.Computed("json_extract(entity_metadata, '$.status')", persisted=True), + sa.Computed("json_extract(entity_metadata, '$.status')", persisted=False), ), ) if not column_exists(connection, "entity", "frontmatter_type"): @@ -118,7 +120,7 @@ def upgrade() -> None: sa.Column( "frontmatter_type", sa.Text(), - sa.Computed("json_extract(entity_metadata, '$.type')", persisted=True), + sa.Computed("json_extract(entity_metadata, '$.type')", persisted=False), ), )