feat(ingestion): add Phase 1 database and application foundation
Add the scoped PostgreSQL/pgvector schema, independent ingestion settings and ports, embedding profile checks, and trusted administrator bootstrap. Include repository contracts and guidance, organized provider-free and PostgreSQL tests, deployment setup, and byte-preserving migration attributes. Validation: 163 tests passed; all 48 PostgreSQL cases passed with pgvector Python 0.5.0 and 0.3.6. No production schema or historical metadata was changed.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
"""Shared database seed and rejection helpers; no test imports."""
|
||||
from uuid import uuid4
|
||||
import pytest
|
||||
from sqlalchemy import text
|
||||
from sqlalchemy.exc import IntegrityError, DataError
|
||||
|
||||
|
||||
def seed(connection):
|
||||
org, actor, document = uuid4(), uuid4(), uuid4()
|
||||
connection.execute(text("INSERT INTO organizations(id,name) VALUES (:id,'test')"), {"id": org})
|
||||
connection.execute(text("""
|
||||
INSERT INTO users(id,organization_id,username,password_hash,role)
|
||||
VALUES (:id,:org,:name,'test-only','admin')
|
||||
"""), {"id": actor, "org": org, "name": str(actor)})
|
||||
connection.execute(text("""
|
||||
INSERT INTO documents(id,organization_id,uploaded_by,title,original_filename,
|
||||
upload_request_id,upload_payload_hash,storage_key,file_sha256,mime_type,
|
||||
size_bytes,processing_profile)
|
||||
VALUES (:id,:org,:actor,'test','test.md',:request,:hash,:key,:hash,'text/markdown',
|
||||
1,CAST(:profile AS jsonb))
|
||||
"""), {"id": document, "org": org, "actor": actor, "request": uuid4(),
|
||||
"hash": "a" * 64, "key": str(document), "profile": "{}"})
|
||||
return org, actor, document
|
||||
|
||||
|
||||
def rejected(engine, sql, params):
|
||||
with pytest.raises((IntegrityError, DataError)):
|
||||
with engine.begin() as connection:
|
||||
connection.execute(text(sql), params)
|
||||
Reference in New Issue
Block a user