bench migrate
The bench migrate command updates an existing Frappe site to match the current state of all installed applications. It applies database changes, executes patches, synchronizes metadata, updates translations, and refreshes system resources after application updates.
Run bench migrate after updating Frappe or installing, updating, or removing apps to ensure the site’s database and configuration remain synchronized.
Command Syntax
bench migrate [OPTIONS]
What the Command Does
During migration, Bench performs several operations in sequence to update the site’s state.
- Runs
before_migratehooks. - Executes all pending application patches.
- Synchronizes the database schema and background jobs.
- Synchronizes fixtures.
- Updates dashboards, desktop icons, and web pages.
- Updates translations.
- Rebuilds the website search index.
- Runs
after_migratehooks.
After a successful migration, Bench also updates the touched_tables.json file and refreshes application version information in the Installed Applications DocType.
Available Flags
| Flag | Description |
|---|---|
--skip-failing |
Continue the migration even if one or more patches fail. |
--skip-search-index |
Skip rebuilding the search index for website documents. |
Examples
1. Run Migration on a Site
bench --site mysite.local migrate
Updates the specified site by applying all pending migrations and synchronization tasks.
2. Skip Rebuilding the Search Index
bench --site mysite.local migrate --skip-search-index
Performs the migration while skipping search index generation for website documents, which can reduce migration time.
3. Skip Failing Patches
bench --site mysite.local migrate --skip-failing
Continues the migration even if one or more patches fail to execute.
Using --skip-failing is not recommended in production environments. Skipping failed patches may leave the database in an inconsistent state and can cause application issues later.
When Should You Run bench migrate?
- After updating the Frappe Framework.
- After updating ERPNext or any custom application.
- After installing a new application.
- After pulling the latest code from version control.
- After making changes that require database schema updates.
Always back up your production site before running bench migrate. Test migrations in a staging environment whenever possible to identify issues before applying changes to live systems.