WordPress Workflow – version control, deployment = database issue

The answer is to try and avoid relaying on configuration changes via the admin interface. Don’t use plugins that you can not configure by filtering options, or better, use only those that have an official API and use the API.

For example if a plugin has an option “pl_option” with which you are happy when its value is 5, do not change the option in the DB via the admin but set it to 5 by using a filter like

add_filter('get_option_pl_option', function () {return 5;});

if in the next version of the plugin the DB structure changes to be an array, you change you code to something like

add_filter('get_option_pl_option', function () {return array('value'=>5;});

This obviously do not prevent from the plugin to make DB changes, but makes your code agnostic to them.

Anyway, having the code in a version control is a small win in any case even if following the suggestion above is not realistic for you.

Leave a Comment