@databricks-solutions/lakebase-scm-utils 0.3.1 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/scripts/index.cjs +26 -9
  2. package/dist/scripts/index.js +27 -10
  3. package/dist/scripts/lakebase/ci-resolve-branch.cli.cjs +26 -9
  4. package/dist/scripts/lakebase/ci-resolve-branch.cli.js +27 -10
  5. package/dist/scripts/lakebase/collapse-heads.cli.cjs +26 -9
  6. package/dist/scripts/lakebase/collapse-heads.cli.js +27 -10
  7. package/dist/scripts/lakebase/detect-language.cli.cjs +26 -9
  8. package/dist/scripts/lakebase/detect-language.cli.js +27 -10
  9. package/dist/scripts/lakebase/doctor.cli.cjs +26 -9
  10. package/dist/scripts/lakebase/doctor.cli.js +27 -10
  11. package/dist/scripts/lakebase/get-connection.cli.cjs +2 -2
  12. package/dist/scripts/lakebase/get-connection.cli.js +2 -2
  13. package/dist/scripts/lakebase/index.cjs +26 -9
  14. package/dist/scripts/lakebase/index.js +27 -10
  15. package/dist/scripts/lakebase/infra-runner.cli.cjs +26 -9
  16. package/dist/scripts/lakebase/infra-runner.cli.js +27 -10
  17. package/dist/scripts/lakebase/new-migration.cli.cjs +26 -9
  18. package/dist/scripts/lakebase/new-migration.cli.js +27 -10
  19. package/dist/scripts/lakebase/schema-diff.cli.cjs +2 -2
  20. package/dist/scripts/lakebase/schema-diff.cli.js +2 -2
  21. package/dist/scripts/lakebase/schema-migrate.cli.cjs +26 -9
  22. package/dist/scripts/lakebase/schema-migrate.cli.js +27 -10
  23. package/dist/scripts/lakebase/scm-claim-feature.cli.cjs +26 -9
  24. package/dist/scripts/lakebase/scm-claim-feature.cli.js +27 -10
  25. package/dist/scripts/lakebase/scm-doctor.cli.cjs +26 -9
  26. package/dist/scripts/lakebase/scm-doctor.cli.js +27 -10
  27. package/dist/scripts/lakebase/scm-merge.cli.cjs +26 -9
  28. package/dist/scripts/lakebase/scm-merge.cli.js +27 -10
  29. package/dist/scripts/lakebase/scm-reconcile-tier.cli.cjs +26 -9
  30. package/dist/scripts/lakebase/scm-reconcile-tier.cli.js +28 -11
  31. package/dist/scripts/util/index.cjs +2 -2
  32. package/dist/scripts/util/index.js +2 -2
  33. package/package.json +1 -1
  34. package/scripts/lakebase/schema-migrate-runners/alembic.ts +58 -14
  35. package/templates/project/client/playwright.config.ts +45 -10
  36. package/templates/project/python/app/database.py +6 -6
  37. package/templates/project/python/app/repositories/__init__.py +8 -0
  38. package/templates/project/python/app/repositories/session.py +28 -0
@@ -0,0 +1,28 @@
1
+ """Request-scoped database session — the repository layer's session door.
2
+
3
+ The ONE place a request obtains a SQLAlchemy `Session`. It lives in the REPOSITORY
4
+ layer (not infrastructure) on purpose: the layering contract is boundary -> service
5
+ -> repository, and ONLY the repository (and the engine in `app.database`) touches the
6
+ session. So a service-backed feature's route NEVER imports the session from
7
+ `app.database`; instead a service exposes `get_session` (re-exporting it) and the route
8
+ depends on that. A simple, non-layered feature may depend on `get_session` directly —
9
+ it is still outside infrastructure, so the boundary stays clean either way.
10
+
11
+ The engine + `SessionLocal` are built once in `app.database` (runtime-minted Lakebase
12
+ token per connection); this module only hands out and closes a session.
13
+ """
14
+
15
+ from collections.abc import Iterator
16
+
17
+ from sqlalchemy.orm import Session
18
+
19
+ from app.database import SessionLocal
20
+
21
+
22
+ def get_session() -> Iterator[Session]:
23
+ """Yield a database session and always close it (FastAPI `Depends` / `with` use)."""
24
+ db = SessionLocal()
25
+ try:
26
+ yield db
27
+ finally:
28
+ db.close()