Skip to main content

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.

Tip:

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.

  1. Runs before_migrate hooks.
  2. Executes all pending application patches.
  3. Synchronizes the database schema and background jobs.
  4. Synchronizes fixtures.
  5. Updates dashboards, desktop icons, and web pages.
  6. Updates translations.
  7. Rebuilds the website search index.
  8. Runs after_migrate hooks.

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.

Warning:

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.
Best Practice:

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.

Rating: 0 / 5 (0 votes)