Generate database schemas for all models in this context. Args: safe: When True, creates tables only if they don't already exist. Raises: ConfigurationError: If context has not been initialized.
(self, safe: bool = True)
| 397 | router.init_routers(router_cls) |
| 398 | |
| 399 | async def generate_schemas(self, safe: bool = True) -> None: |
| 400 | """ |
| 401 | Generate database schemas for all models in this context. |
| 402 | |
| 403 | Args: |
| 404 | safe: When True, creates tables only if they don't already exist. |
| 405 | |
| 406 | Raises: |
| 407 | ConfigurationError: If context has not been initialized. |
| 408 | """ |
| 409 | from tortoise.utils import generate_schema_for_client |
| 410 | |
| 411 | if not self._inited: |
| 412 | raise ConfigurationError( |
| 413 | "Context not initialized. Call init() before generating schemas." |
| 414 | ) |
| 415 | for connection in self.connections.all(): |
| 416 | await generate_schema_for_client(connection, safe) |
| 417 | |
| 418 | def get_model(self, app_label: str, model_name: str) -> type[Model]: |
| 419 | """ |