make lint test (tests/test_db.py — sqlite in-memory, две БД)
На compose-Postgres: TEST_PG_IDENTITY_URL=postgresql+asyncpg://identity_app:identity_app@127.0.0.1:5432/identity TEST_PG_CLINICAL_URL=postgresql+asyncpg://clinical_app:clinical_app@127.0.0.1:5432/clinical uv run pytest tests/test_db.py
Two DeclarativeBases on two engines (ADR-003): identity holds direct
identifiers, clinical holds token-keyed pseudonymised data plus audit_log.
Portable types (JSONB variant, tz-aware UTC timestamps rejecting naive
values) so tests run on SQLite. init_db() runs create_all at startup.
Guardrail #5 checked by AST and import-graph tests.
Refs #6
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Что меняется
Модель данных: две раздельные БД (identity / clinical + audit_log) на SQLAlchemy 2.0 async, тонкие репозитории,
init_db()(create_all) на старте приложения. Guardrail #5 проверяется тестами.Closes #6
Зона
backend
Как проверить
make lint test(tests/test_db.py— sqlite in-memory, две БД)TEST_PG_IDENTITY_URL=postgresql+asyncpg://identity_app:identity_app@127.0.0.1:5432/identity TEST_PG_CLINICAL_URL=postgresql+asyncpg://clinical_app:clinical_app@127.0.0.1:5432/clinical uv run pytest tests/test_db.pymake up→ в логе appdb schema readyПубличный API
app.db.session:get_identity_session(),get_clinical_session()(commit/rollback),configure(identity_url=, clinical_url=),dispose()app.db.bootstrap.init_db()app.db.repo:upsert_profile,get_profile,patients_of_doctor,upsert_checkin,list_checkins,add_item_response,add_scale_result,list_scale_results,add_alert,open_alert_codes,list_alerts,ack_alert,get_dialog_state,set_dialog_state,add_message,load_clock_offset,save_clock_offsetapp.db.audit.audit(...),app.db.identity_repo.*Чек-лист
app/main.pylifespan)