Something went wrong. Try again.
Nix Packages collection & NixOS github.com/NixOS/nixpkgs
Something went wrong. Try again.
2.2 kB · 66 lines
at master
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667From db03b44068e71f5266b720eb68ecae50e3e14303 Mon Sep 17 00:00:00 2001From: Ewerton Silva <ewertoncom297@gmail.com>Date: Sat, 11 Jul 2026 23:50:58 -0300Subject: [PATCH] fix: do not commit inside the content_hash embeddings migration
--- llm/embeddings_migrations.py | 21 ++++++++++----------- tests/test_migrate.py | 12 ++++++++++++ 2 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/llm/embeddings_migrations.py b/llm/embeddings_migrations.pyindex 96444bd65..595a692d9 100644--- a/llm/embeddings_migrations.py+++ b/llm/embeddings_migrations.py@@ -62,17 +62,16 @@ def random_md5(): db.conn.create_function("temp_md5", 1, md5) db.conn.create_function("temp_random_md5", 0, random_md5) - with db.conn:- db.execute("""- update embeddings- set content_hash = temp_md5(content)- where content is not null- """)- db.execute("""- update embeddings- set content_hash = temp_random_md5()- where content is null- """)+ db.execute("""+ update embeddings+ set content_hash = temp_md5(content)+ where content is not null+ """)+ db.execute("""+ update embeddings+ set content_hash = temp_random_md5()+ where content is null+ """) db["embeddings"].create_index(["content_hash"]) diff --git a/tests/test_migrate.py b/tests/test_migrate.pyindex 705021100..e74b1554b 100644--- a/tests/test_migrate.py+++ b/tests/test_migrate.py@@ -117,6 +117,18 @@ def test_migrations_for_embeddings(): assert db["embeddings"].foreign_keys[0].other_table == "collections" +@pytest.mark.skipif(+ not hasattr(sqlite_utils.Database, "atomic"),+ reason="sqlite-utils 4 and higher run each migration inside a transaction",+)+def test_embeddings_migrations_do_not_commit():+ # https://github.com/simonw/llm/issues/1523+ db = sqlite_utils.Database(memory=True)+ for migration in embeddings_migrations.pending(db):+ with db.atomic():+ migration.fn(db)++ def test_backfill_content_hash(): db = sqlite_utils.Database(memory=True) # Run migrations up to but not including m004_store_content_hash