Create all OrgKernel tables in the database. Call this once at application startup (after setting the engine URL). Args: engine: AsyncEngine to use. Defaults to the global async_engine. Note: On PostgreSQL, run ``CREATE EXTENSION IF NOT EXISTS pgcrypto;``
(engine: AsyncEngine | None = None)
| 74 | |
| 75 | |
| 76 | async def init_db(engine: AsyncEngine | None = None) -> None: |
| 77 | """ |
| 78 | Create all OrgKernel tables in the database. |
| 79 | |
| 80 | Call this once at application startup (after setting the engine URL). |
| 81 | |
| 82 | Args: |
| 83 | engine: AsyncEngine to use. Defaults to the global async_engine. |
| 84 | |
| 85 | Note: |
| 86 | On PostgreSQL, run ``CREATE EXTENSION IF NOT EXISTS pgcrypto;`` first |
| 87 | to enable SHA-256 hashing functions. |
| 88 | """ |
| 89 | global async_engine |
| 90 | target_engine = engine or async_engine |
| 91 | if target_engine is None: |
| 92 | raise RuntimeError( |
| 93 | "No engine set. Pass an engine argument or set orgkernel.database.async_engine.url first." |
| 94 | ) |
| 95 | async with target_engine.begin() as conn: |
| 96 | await conn.run_sync(BaseModel.metadata.create_all) |
| 97 | |
| 98 | |
| 99 | async def close_db() -> None: |
nothing calls this directly
no outgoing calls
no test coverage detected