<!-- SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -->
<!-- SPDX-License-Identifier: Apache-2.0 -->

Generic single-database configuration.

## Generating and running migrations

When you change the entities schema (e.g. tables in `src/nmp/core/entities/app/repository/sqlalchemy/models.py`), create and apply a migration as follows. Run all commands from the **service root** (`services/core/entities/`).

**Prerequisites:** A running PostgreSQL (or set `DATABASE_URL` / `DATABASE_*` env vars). The migration env uses `DatabaseConfig` from `nmp.common.config` when no URL is set in `alembic.ini`.

1. **Generate a new revision** (autogenerate from current models):
   ```bash
   uv run alembic revision --autogenerate -m "Short description of the change"
   ```
   New file appears under `alembic/versions/`. Review the generated `upgrade()` and `downgrade()` and fix any missing or incorrect operations.

2. **Apply migrations** (e.g. local DB or before tests):
   ```bash
   uv run alembic upgrade head
   ```

3. **Other useful commands:**
   - `uv run alembic current` — show current revision
   - `uv run alembic history` — list revisions
   - `uv run alembic downgrade -1` — roll back one revision
