MigrationManager class provides a programmatic way to manage database schema migrations for Agno database tables.
Constructor
Parameters
The database instance to run migrations on. Supports both synchronous and asynchronous database classes.
Properties
Returns the latest available schema version from the migration versions list.
A list of available migration versions as tuples of (version_string, parsed_version).Currently available versions:
v2_0_0(2.0.0)v2_3_0(2.3.0)
Methods
up()
Executes upgrade migrations to bring database tables to a target schema version.Parameters
The version to migrate to (e.g., “2.3.0”). If not provided, migrates to the latest available version.
The specific table type to migrate. If not provided, all tables will be migrated.Valid values:
"memory", "session", "metrics", "eval", "knowledge", "culture"Force the migration even if the current version is equal to or greater than the target version.
Example
down()
Executes downgrade migrations to revert database tables to a target schema version.Parameters
The version to migrate down to (e.g., “2.0.0”). This parameter is required for down migrations.
The specific table type to migrate. If not provided, all tables will be migrated.Valid values:
"memory", "session", "metrics", "eval", "knowledge", "culture"Force the migration even if the current version is equal to or less than the target version.
Example
Supported Databases
TheMigrationManager supports the following database types:
- PostgreSQL (via
PostgresDborAsyncPostgresDb) - SQLite (via
SqliteDborAsyncSqliteDb) - MySQL (via
MySQLDb) - SingleStore (via
SingleStoreDb)
Table Types
The following table types can be migrated:| Table Type | Description |
|---|---|
memory | Agent memory storage |
session | Agent session data |
metrics | Performance and usage metrics |
eval | Evaluation results |
knowledge | Knowledge base entries |
culture | Culture and behavior data |