# `sandloom.sdk.migrations`

Running migrations: `run_module_migrations`, `run_migrations`.

Public API 1.0 (spec §2.2, Appendix C).

`from sandloom.sdk.migrations import <name>`. Signatures in a terminal: `sandloom docs <name>`. Beginner names are the ones generated code and the examples use; any other name is advanced (mark its import line `# sandloom: advanced <reason>` in generated code and examples).

## Advanced

| Name | Kind | Summary |
| --- | --- | --- |
| [`run_migrations`](<#run_migrations>) | function | Run the active alembic chain scoped to the chain's own tables. |
| [`run_module_migrations`](<#run_module_migrations>) | function | Run a module's own migration chain by convention (from its env.py). |

## Advanced names

### `run_migrations`

```
def run_migrations(
    table_names: Iterable[str] = (),
    model_modules: Sequence[str] = (),
    *,
    table_prefix: str | None = None,
) -> None
```

Run the active alembic chain scoped to the chain's own tables.

## Parameters

table\_names: Explicit set of tables this chain owns (used by the framework's hand-written chains, whose tables do not share a single prefix). model\_modules: Importable module paths whose import registers the chain's models on the shared `Base.metadata` (e.g. `"sandloom_identity.models"`). table\_prefix: Alternative scoping for scaffolded modules, which follow the `<module>_` table-name convention: every table starting with this prefix is owned by the chain. Combined with `table_names` (union).

Autogenerate is restricted to the owned tables (and the indexes/constraints attached to them) via `include_object`; at upgrade time the filter is a no-op (the migration ops run as written).

### `run_module_migrations`

```
def run_module_migrations(
    env_file: str | os.PathLike[str],
    *,
    package: str | None = None,
    model_modules: Sequence[str] | None = None,
    table_prefix: str | None = None,
    table_names: Iterable[str] = (),
) -> None
```

Run a module's own migration chain by convention (from its env.py).

See `sandloom.core.migrations.alembic_support.run_module_migrations`.

## Examples and related guides

- [Run migrations](<https://sandloom.dev/docs/modules/database/run-migrations/index.md>)
- [Python API overview](<https://sandloom.dev/docs/reference/sdk/index.md>)
