Skip to main content
The MigrationManager class provides a programmatic way to manage database schema migrations for Agno database tables.

Constructor

Parameters

Union[AsyncBaseDb, BaseDb]
required
The database instance to run migrations on. Supports both synchronous and asynchronous database classes.

Properties

Version
Returns the latest available schema version from the migration versions list.
list[tuple[str, Version]]
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

str
The version to migrate to (e.g., “2.3.0”). If not provided, migrates to the latest available version.
str
The specific table type to migrate. If not provided, all tables will be migrated.Valid values: "memory", "session", "metrics", "eval", "knowledge", "culture"
bool
default:"False"
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

str
required
The version to migrate down to (e.g., “2.0.0”). This parameter is required for down migrations.
str
The specific table type to migrate. If not provided, all tables will be migrated.Valid values: "memory", "session", "metrics", "eval", "knowledge", "culture"
bool
default:"False"
Force the migration even if the current version is equal to or less than the target version.

Example

Supported Databases

The MigrationManager supports the following database types:
  • PostgreSQL (via PostgresDb or AsyncPostgresDb)
  • SQLite (via SqliteDb or AsyncSqliteDb)
  • MySQL (via MySQLDb)
  • SingleStore (via SingleStoreDb)

Table Types

The following table types can be migrated:

See Also