Repository navigation
Add local Postgres schema and swellsense db init - #42
Merged
Merged
Conversation
Docker Compose runs pgvector on localhost; init applies idempotent SQL and checks embedding dimension against settings. Co-authored-by: Cursor <cursoragent@cursor.com>
Psycopg 3 does not commit on close; persist init_schema and CLI db init with explicit commits and tests that reconnect after init. Co-authored-by: Cursor <cursoragent@cursor.com>
init_schema only registers Vector on the connection it receives; a fresh psycopg.connect needs register_vector before INSERT can adapt embeddings. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
XQU-25: Slice 4 local Postgres schema, compose, and
swellsense db init.Acceptance criteria:
documentsandchunks,vector(768), HNSWchunks_embedding_hnsw/vector_cosine_ops,IF NOT EXISTS/CREATE EXTENSION) with no DBinit_schemacallsconn.commit()after applying schema.sql, the dimension check, andregister_vector_db_initcallsconn.commit()beforeconn.close()(order is commit then close; do not switch to autocommit)connect/init_schema,main(["db", "init"])records["commit", "close"]dband skipped unless DATABASE_URL is setdb:main(["db", "init"]), close, reconnect,SELECT to_regclass('public.chunks')ischunksand same fordocumentsregister_vector(orswellsense.db.connect()) on the new connection before the Vector INSERT, and still rolls back DMLswellsense db initexists; a connection failure prints one stderr line and exits 1pgvector/pgvector:pg17, localhost-only port (127.0.0.1:5432:5432), named volumepsycopg[binary]andpgvectordb/layout line and compose/db initcommandsfed5f7etouches onlytests/test_db_schema.pyReview: all checks passed. check.sh: CHECK PASSED locally.
Post-merge smoke test (not a merge gate):
docker compose up -d && uv run swellsense db init.Made with Cursor