Skip to content

[codex] add DatabaseModule root registration#133

Draft
ItayTheDar wants to merge 1 commit into
mainfrom
nonstop-cherry
Draft

[codex] add DatabaseModule root registration#133
ItayTheDar wants to merge 1 commit into
mainfrom
nonstop-cherry

Conversation

@ItayTheDar
Copy link
Copy Markdown
Contributor

What changed

  • add DatabaseModule.for_root(...) as a global root-module entry point for SQLAlchemy setup
  • export DatabaseModule, DatabaseService, and the related injection tokens from nest.core.database
  • add lifecycle-aware schema and session management through DatabaseService
  • guard against duplicate DatabaseModule.for_root() registrations in a single application
  • allow later provider bindings to replace earlier ones so app-level overrides can replace the default database service
  • update ORM template tests to assert the generated code uses DatabaseModule and injected DatabaseService

Why

The framework needed a first-class database root module instead of relying on the older provider/config pattern in generated apps. This change gives applications a single place to register database configuration, exposes a consistent injected service API for sync and async sessions, and makes the module system reject unsupported duplicate root registrations.

Impact

Applications can now configure SQLAlchemy integration from the root module and inject DatabaseService in feature services. The new tests cover provider registration, duplicate-root protection, lifecycle behavior, HTTP integration, async queries, and generated ORM template output.

Validation

  • uv sync --group test
  • uv run pytest tests/test_core/test_database/test_database_module.py tests/test_cli/test_orm_templates.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant