最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Sync plugin settings (wp_options table) on multiple environments

programmeradmin1浏览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 :)

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 :)

Share Improve this question asked Aug 12, 2019 at 13:11 Johan van der MolenJohan van der Molen 31 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 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/danielbachhuber/dictator which looks like it is unmaintained but might give you a head start on one possible approach.

发布评论

评论列表(0)

  1. 暂无评论