Last active
August 29, 2015 14:23
-
-
Save laurieainley/8a4f507c53237bad1652 to your computer and use it in GitHub Desktop.
Merging WordPress installations following site upgrades in an isolated development environment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When developing a WordPress site in a development environment with an existing | |
production environment serving live traffic, updates need to be merged back | |
into the production environment. With major upgrades, this can involve both | |
codebase and database changes. While WordPress excels in providing a simple | |
way to introduce new functionality easily by installing plugins, the absence | |
of database schema migration scripts makes it difficult to deploy changes to | |
an existing installation. | |
As the production site typically has content being added to it which needs to | |
be preserved while the development site may have schema changes, it's necessary | |
to retain the content tables while updating all other tables. This could be due | |
to updating WordPress itself, updating plugins, installing new plugins, applying | |
new settings or introducing custom tables. It's possible to take the following | |
tables from the production database and merge them into the development version, | |
resulting in an updated installation with the most current content: | |
# Articles (posts, pages, custom posts) and metadata | |
TRUNCATE wp_postmeta; | |
TRUNCATE wp_posts; | |
# Comments and associated metadata | |
TRUNCATE wp_commentmeta; | |
TRUNCATE wp_comments; | |
# User login information and associated metadata | |
TRUNCATE wp_users; | |
TRUNCATE wp_usermeta; | |
# Taxonomy related data (categories and tags) | |
TRUNCATE wp_terms; | |
TRUNCATE wp_term_relationships; | |
TRUNCATE wp_term_taxonomy; | |
# Links (deprecated but may still exist in older installations) | |
TRUNCATE wp_links; | |
After clearing these tables, content from the production environment can be | |
inserted into them. | |
More information about the WordPress database structure can be found here: | |
https://codex.wordpress.org/Database_Description |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment