Deploy pre-configured database

I would like to version control my WP sites with git. A big struggle I have with this is: how do you version control options/plugin settings in the database.

I would like to don’t touch the dashboard in the live site. Only the users should need to login in to write posts – but I as a developer would like to log in only to check if everything is working on the live machine. Is there a way to do this?

I know that Drupal 8 has a build in configuration management – that’s their solution. I also know “versionpress” and similar plugins. But they also version control the posts/pages/users etc. I don’t need this. Example:

Update option 'site_url' to 'http://example.com';
Reset update option 'site_url' to 'http://noexample.com';```

(the second line is to redo this step)

I guess there are some things in ruby on rails or similar. Would be great to separate code/options/settings and content/media/user-generated-stuff.

4 Answers
4

WP-CFM is probably the closest to what you’re looking for. Actually, it has been inspired by Drupal’s Features module.

From the plugin page:

WP-CFM lets you copy database configuration to / from the filesystem. Easily deploy configuration changes without needing to copy the entire database.

However, as someone who has spent the better part of the past few years working on the versioning solution for WordPress (I’m a co-creator of VersionPress), I can say that it’s tricky to version-control only parts of the site. For example, a plugin might store some of its configuration in wp_options, some of it on the disk (in some PHP file, for instance) and some of it in postmeta or whatever. Full version control is hard (which is why VersionPress takes its time) but it’s the only 100% reliable way.

If you’re sure you good with just wp_options (and some other tracked entities that WP-CFM provides; see the linked plugin page) then I agree that it’s better to use the simpler tool.

Leave a Comment