> ## Documentation Index
> Fetch the complete documentation index at: https://askmarvin.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Database Migrations

> Inspect and upgrade the database used for thread history

Marvin uses SQLAlchemy and Alembic for the database that stores threads, messages, and model-call usage. This database is separate from vector memory.

The default database is `~/.marvin/marvin.db`. SQLite initialization is enabled by default. Configure another location with an async database URL:

```bash theme={null}
export MARVIN_DATABASE_URL="sqlite+aiosqlite:////absolute/path/to/history.db"
```

For PostgreSQL, install an async driver such as `asyncpg` and use a `postgresql+asyncpg://...` URL.

## Inspect and upgrade

```bash theme={null}
marvin db status
marvin db current
marvin db history
marvin db upgrade
```

Run these commands against the same `MARVIN_DATABASE_URL` used by the application. Back up stored history before applying schema changes.

`marvin db downgrade REVISION` reverts to a specific revision. `marvin db reset` downgrades to the base schema and upgrades again, deleting stored data. Both prompt for confirmation; `--yes` skips the prompt.

## Create a migration in a checkout

```bash theme={null}
uv run marvin dev db revision --autogenerate -m "Describe the schema change"
```

Review the generated migration before applying it. Alembic cannot infer every data transformation. Migration sources and developer instructions are in [migrations/](https://github.com/PrefectHQ/marvin/tree/main/migrations).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.