0

How do you guys handle database changes, more specifically the settings (wp_options)?

Im looking for something like, having a JSON file (or migration files bit similar like Laravel) with settings, that I can run after a deployment.

For example once I install WooCommerce I have a list with default settings (presets) I want to use and import at once. But also once I add a new feature or plugin that I can migrate those settings across multiple environments.

Would be cool if that JSON file (or settings file) is environment based. So I can use test payment method settings on local and live settings on production. And just run a command like wp migrate options or something in my deployment script, which sets all the correct settings for that environment.

Is there something like that?

Thanks in advance :)

0

This is a tricky one since even if you might get it to work with Core with plugins you never know if they also store data in files, custom tables, post types and so in. If you then only sync the options table you might get inconsistent/partial/broken states. Also you probably don't want to sync everything since some things like transients are on the options table but aren't really settings.

This is a general problem with systems that store configuration in the database and even more so with WP since the data storage formats are somewhat fragile.

If you search the web or this site you'll see that there have been plenty of questions and attempts of approaching this. But there is no general best practice solution to it.

Having said that, concerning your specific request you can have a look at https://github.com/danielbachhuber/dictator which looks like it is unmaintained but might give you a head start on one possible approach.

  • Thanks :) i will take a look at it! – Johan van der Molen Aug 19 at 9:28
  • Since you're new here just a quick reminder that the way this site works is that you press the up arrow next to an answer if you think it is helpful, or mark it as accepted if it solves your problem. Not saying this for my owns sake, but because this is how this site generally works by pushing up helpful answers (and rewarding voluntary helpers) – kraftner Aug 20 at 8:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.