MigrationManager class:
libs/agno/migrations directory.
The MigrationManager class supports the following databases:
- PostgreSQL
- SQLite
- MySQL
- SingleStore
AsyncPostgresDb and AsyncSqliteDb) with your migrations.
How It Works
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
When using AgentOS, it is recommended that you run the migrations in a separate script and restart the AgentOS for the updated schema’s to take effect.
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.