docs/administrator/migration/database_schema_and_migration.md
Sync schemas and migrate data using official RAGFlow scripts.
RAGFlow handles schema updates and migrations automatically at startup. However, for high-volume environments like Kubernetes, massive datasets can cause initialization to exceed 10 minutes, potentially triggering container timeouts or health check failures. To avoid this, you can disable the built-in auto-initialization and manually run these provided scripts to complete database upgrades before launching the service:
The mysql_migration.py script is a specialized tool for re-organizing RAGFlow’s model-related data. It transitions data from older unified tables into a modern, multi-table structure to support advanced model management.
--create-table-only flag before main services start.The db_schema_sync.py script is a synchronization utility that ensures your MySQL database structure matches the Peewee ORM models defined in the RAGFlow source code.
api/db/db_models.py against the live database to identify new tables, added fields, or type mismatches.migrate() and rollback() logic) in version-specific directories (e.g., tools/migrate/v0_25_0/).--diff command to view structural discrepancies without applying changes.--drop flag to generate DROP COLUMN statements for removed fields.db_models.py and needing to update your local database without manual SQL.