- Use the AgentOS migration endpoints: This is the easiest option when using AgentOS. You just need to make a POST request.
- Migrate manually using the
MigrationManager: If you prefer a more controlled migration experience, you can use the MigrationManager class to upgrade or downgrate your schemas.
Using the AgentOS Migration Endpoints
If you are using the AgentOS, you can handle your migration needs via the migration endpoints. You can read more about it in the AgentOS Database Migrations page.Migrate manually using the MigrationManager
All migrations are ultimately handled by theMigrationManager class.
You can use it directly to have total control over your migration process, or use one of the supporting scripts we provide.
Using it directly looks like this:
libs/agno/migrations directory.
About the MigrationManager
TheMigrationManager:
- Creates an
agno_schema_versionstable to track schema versions for each table - Checks the current schema version of each table
- Applies migrations in order from the current version to the target version
- Updates the schema version record after successful migration
- Supports both synchronous and asynchronous database operations
- PostgreSQL
- SQLite
- MySQL
- SingleStore
AsyncPostgresDb and AsyncSqliteDb) are also supported.
See the MigrationManager page for more information.
Upgrade a specific table
You can also upgrade a specific table:session, memory, metrics, eval, knowledge, culture.
Reverting Migrations
You can also use theMigrationManager class to revert a migration:
Troubleshooting
- Schema mismatch errors
- Invalid Column Errors
- SQL INSERT Errors
If you continue to see errors and are not able to read or write to the database, it’s likely due to a mismatch between the schema version and the actual schema of the table.Please set the
force parameter to True to force the migration for a specific table.Migrating from Agno v1 to v2
If you started using Agno during its v1 and want to move to v2, we have a migration script that can help you update your database tables. You can find the script in thelibs/agno/migrations/v1_to_v2/migrate_to_v2.py file.
You can find more information about migrating from v1 to v2 in the Migrating to Agno v2 guide.