WP Migrate DB Pro 1.8 Released: Import SQL File & More

#
By Peter Tasker

The WP Migrate DB Pro team is very excited to announce the release of version 1.8! We’ve packed in an awesome new feature and improved a bunch of existing functionality. So without further ado, let’s go over what’s new!

Import any SQL file

YouTube cover image

Remember in the old days you would export your file from WP Migrate DB Pro and then have to import said export through phpMyAdmin? Well no more! The biggest new feature in version 1.8 is the addition of the SQL Import functionality.

WP Migrate DB Pro can now import any MySQL exports generated by other tools and run a find and replace on the imported data. And if you import an export generated by WP Migrate DB Pro, it will pre-fill the find and replace fields automatically for you.

The pre-population magic is actually handled by some special SQL comments we now add to the header of a WP Migrate DB Pro export file. If these comments are absent, as with a phpMyAdmin export, there is no magic 😢 but you can still import just fine. You’ll just have to manually add your own find and replace values to run after the file is imported.

Current WP Migrate DB Pro users will notice the familiar migration progress interface when running imports. There are 2 new steps involved, the upload of the SQL file and the actual import of the SQL, after which the well-known find and replace is run.

We took extra care to make sure that even the largest files can be uploaded easily – the upload portion of the import uses the HTML5 FileReader API to split the export file up and upload it over multiple requests. This means that the import feature should work on any host, regardless of the upload limits or max request size.

We’ve also added a new CLI import sub-command to the CLI Addon. You can run it with the following command:

wp migratedb import <import-file> [--find=<strings>] [--replace=<strings>] [--backup=<prefix|selected|table_one,table_two,table_etc>]

If you’re into scripting your dev workflow (who isn’t?), this is an awesome addition. You could use this command to load in a starter WordPress database and have a new development environment set up in a flash!

This feature is an awesome complement to WP Migrate DB Pro’s Export functionality and will not only speed up the backup/restore process but allow you to run migrations around firewalls and complicated hosting setups where MDB is unable to make a connection between sites.

You can read more about Import migrations in the documentation. Hat tip to Matt for implementing this great new feature!

Plugins and Themes Disabled by Default

Another big change in this release is that plugins and themes are prevented from loading during WP Migrate DB Pro migration requests with Compatibility Mode.

Prior to version 1.8, Compatibility Mode was an optional setting that allowed you to control which WordPress plugins were loaded for requests made by WP Migrate DB Pro. This was done by adding an MU (must use) plugin. A regular WordPress plugin isn’t able to control which plugins are loaded and which aren’t. So what Compatibility Mode did was add an MU plugin when you toggled Compatibility Mode on.

As of version 1.8 Compatibility Mode still uses an MU plugin but is enabled by default when you install or upgrade WP Migrate DB Pro. We did this largely because in support requests we often ask ‘Have you tried enabling Compatibility Mode?’. Because of this, we figured why not disable themes and plugins by default? So that’s what we did.

How we do this is by unloading some options in the wp_options table using the option_{$option} filter, we never actually touch plugins or files.

In the unlikely event that you need to disable Compatibility Mode (remember, it’s on by default now), you can switch it off in the Settings tab:

Overall this should result in faster, more reliable migrations. For more details about Compatibility Mode, check out our documentation.

Reloading After Migrations

One of the things that always bothered us was having to refresh the WP Migrate DB Pro page after pulling in a another site. If you don’t reload you’ll often see invalid-nonce errors or strange behaviour if you try to run another migration or change settings before refreshing and logging back in.

To fix this we now reload the page if you pull in the wp_options, wp_users or wp_usermeta tables.

Handling of utf8mb4_unicode_520_ci

Have you seen this error on your site during a migration?

WordPress database error: [Unknown collation: 'utf8mb4_unicode_520_ci']

This can crop up in WordPress 4.6+ when you’re migrating from a site that’s using a certain type of MySQL multibyte encoding (utf8mb4_unicode_520_ci in MySQL 5.6+) to a site that isn’t (utf8_unicode_ci in < MySQL 5.5). In case you’re wondering, multibyte encoding allows for special characters like emojis (🍔) to be used in your post content without issue.

In version 1.8 we’re now checking if your MySQL server works with this multibyte encoding and doing some lower level compatibility checking to make sure content is migrated between these different versions.

This under the hood addition should help make sure your migrations run as smooth as 🥞(butter on pancakes).

And more

We’ve also included a bunch of other bug fixes and improvements:

  • Diagnostic Log – Added additional information to the diagnostic log to help us help you, should you run into trouble with WP Migrate DB Pro
  • Handling Invalid Characters – Helpful error message for migrations that fail due to invalid characters in the database with optional stripping of invalid characters provided by a new constant.
  • wp_site and wp_blogs tables – Find & Replace now runs on the wp_site and wp_blogs tables in multisite installs

You can see a full list of changes in the changelog.

Next up

Not to be outdone, but we’re planning our next version to be an even bigger release. It’s going introduce a brand new addon that will migrate theme and plugin files between sites.

You read that right.

The goal is to allow you to move a complete site, database, media AND theme/plugin files between WordPress installs. It’s a tall order, but we’ve got a head start on planning and have a path forward.

The plan is for all of us on #team-mdb (  ) to work on this addon together – at the same time. We might even put together a new base transfer module for the entire plugin. No sweat…

Phew! That was a big release. Excuse me while I take a breather. Cheers!

About the Author

Peter Tasker

Peter is a PHP and JavaScript developer from Ottawa, Ontario, Canada. In a previous life he worked for marketing and public relations agencies. Love's WordPress, dislikes FTP.