Fix data loss after migration from V1

If you experienced a data loss from V1 after migration follow this guide.

Before applying the fix it is recommended to backup your DB

Data loss in option page fields

The persisting strategies of V1 and V2 are slightly different.

Suppose you have a field email inside a box called box associated with a page having new-pageas slug.

In v1 the meta field is saved with this name:

box_email

In v2 instead, the field is saved with this name:

new-page_box_email

This is because in V2 a meta field can be shared between several pages.

How to restore the data

You need access to your DB.

You can use PHPMyAdmin, or this plugin instead.

If you don't see the option page meta fields, they are saved with the wrong key.

Launch this query (use the correct WordPress tables prefix) to seek the data saved in box:

SELECT * from wp_options where option_name LIKE 'box_%';

If you don't have records from the previous query, launch this one:

SELECT * from wp_options where option_name LIKE 'new-page_new-page_box_%';

In both cases, you need to restore option_name to the right name.

Launch this query to fix the field if you got results from the first query;

UPDATE wp_options set option_name = REPLACE(option_name, "box_","new-page_box_") where option_name LIKE 'box_%';

Instead, launch this query if you got results from the second query:

UPDATE wp_options set option_name = REPLACE(option_name, "new-page_new-page_box_","new-page_box_") where option_name LIKE 'new-page_new-page_box_%';

Now the data inside box should be restored.

Check it out by launching this query:

SELECT * from wp_options where option_name LIKE 'new-page_box_%';

You should finally see your data with the correct key.

Last updated