Skip to main content

Database Migrations

Aegis Memory manages its PostgreSQL schema with Alembic. Migrations live in alembic/versions/ and are configured by alembic.ini.
Aegis requires PostgreSQL with the pgvector extension. The baseline migration enables vector; ensure the extension is available to your database role before upgrading.

Applying migrations

Apply all pending migrations up to the latest revision:
Alembic reads the database URL from your environment (the same Postgres settings the server uses — see the Production Checklist). Run this once per deployment, before starting the API server, whenever you upgrade Aegis to a version that ships new migrations.

Inspecting state

Revision history

Migrations are linear and applied in order. As of v2.6.x:

Downgrades

Downgrades can drop columns and therefore lose data. Take a backup first (see Backup & Restore) and prefer rolling forward with a new migration over downgrading a production database.

Creating a new migration

When you change the models, autogenerate a revision and review it before committing:
Always inspect the generated script — autogenerate does not detect every change (for example, some index or server-default edits) and should be treated as a starting point.