WordPress Database Sync for CI/CD: 3 Strategies That Actually Work
The Real Problem With WordPress Database Sync
Your code is in Git. Your CI pipeline runs clean. Staging mirrors production. Everything about your WordPress DevOps pipeline is dialed in — until someone asks: “But what about the database?”
This is the question that trips up even experienced teams. And it’s the question we get asked more than almost anything else.
Because WordPress stores everything in the database — theme settings, ACF field configurations, widget layouts, menu structures, WooCommerce products, customer orders, Customizer options. And unlike code, database changes don’t travel through Git.
So when your client is publishing blog posts on production while your developer is configuring custom fields on staging — you’ve got a conflict. And if someone pushes the staging database to production, those blog posts are gone.
We’ve seen it happen. More than once.
This post breaks down the three database sync strategies that actually work in a WordPress CI/CD environment — based on what we use across dozens of client sites and what the best teams in the WordPress ecosystem have converged on.
Why WordPress Database Sync Is Harder Than You Think
In a typical web application, e.g., Laravel, database changes are handled through migration files — versioned scripts that modify schema and data in a predictable, repeatable way. Laravel developers take this for granted.
WordPress doesn’t work that way.
Plugins and themes write to the database in unpredictable patterns. Every plugin has its own storage conventions. ACF stores field groups in wp_posts and wp_postmeta. WooCommerce uses custom tables for orders (since HPOS). Gravity Forms has its own entry tables. The WordPress Customizer saves settings as serialized arrays in wp_options.
This means there’s no universal “diff” tool that can compare two WordPress databases and cleanly merge them. As the team at Delicious Brains puts it, for every plugin that writes to the database, you need to understand how it stores data to correctly handle IDs and conflicts — and that understanding breaks every time a plugin updates its storage schema.

That’s why you need a strategy, not a tool.
Strategy 1: Separate Code From Content (The Production-Is-Truth Model)
This is the most practical approach for the majority of WordPress sites — and it’s the one we default to at onPoint Studio for every devops WordPress project.
The principle
Production is the source of truth for content (posts, pages, products, orders, user data). Staging is for validating code and configuration changes only. You never push the staging database to production after launch.
How it works
- Code flows one direction: Local > Git > CI > Staging > Production
- Content lives in production and is never overwritten by a deploy
- When developers need real content to test against, they pull a copy of production DB down to staging or local — one-way only
- Database changes that are part of a feature (new options, custom tables, ACF field registrations) get handled in code through migration scripts
When to use it
This works best for sites where clients actively update content — blogs, WooCommerce stores, membership sites, any site with user-generated content. Which is most sites.
The tradeoff
Configuration changes made through the WordPress admin (Customizer settings, menu structures, widget layouts) need to be re-applied manually on production after deploy. For most teams, this is a small price to pay for never accidentally overwriting production data.
This is exactly the approach we describe in our complete WordPress DevOps and CI/CD guide — and it’s the foundation that makes the other strategies possible.
Strategy 2: Migration Scripts (The Code-As-Database-Change Model)
This is the approach for teams that want every database change tracked, versioned, and deployable — the gold standard for WordPress enterprise CI/CD.

The principle
Instead of making database changes through the WordPress admin and then trying to sync them, you write those changes as PHP scripts that execute during deployment. Every schema change and data update is a file in your repository.
How it works
The WP Migrations library from Delicious Brains (inspired by Laravel migrations) is the best implementation of this pattern. Here’s the workflow:
- Developer needs to add a new page with a specific template? Write a migration script that calls
wp_insert_post()andupdate_post_meta() - Need to update an option value? Write a migration that calls
update_option() - Need to add a custom database table? Write a migration with the
dbDelta()call - Run
wp dbi migratevia WP-CLI during your CI/CD deploy step — only new migrations execute - Every migration supports rollback, so you can reverse changes if something breaks
What this looks like in a real pipeline
In a WordPress continuous integration pipeline using tools like Buddy Works, DeployHQ, or GitHub Actions, your deploy step would include:
# After deploying code to production
wp dbi migrate # Run pending database migrations
wp cache flush # Clear object cache
wp rewrite flush # Rebuild permalinks
As the SpinupWP team recommends, this approach works best when set up at the start of the project. Retrofitting migration scripts onto an existing site is possible but requires more discipline.
When to use it
Enterprise projects, multi-developer teams, sites with complex custom post types and ACF configurations, WooCommerce stores with custom checkout flows. Any project where you need a full audit trail of what changed, when, and why.
The tradeoff
It requires developer discipline. Every database change must be scripted, not clicked. Teams used to configuring things through the WordPress admin will need to adjust. But once the habit forms, you’ll never want to go back.
Strategy 3: Selective Table Sync (The Surgical Approach)
Sometimes you do need to move database content between environments — but you need to be surgical about it. This is where selective sync comes in, and it’s critical for any mature WordPress DevOps setup.
The principle
Instead of pushing or pulling the entire database, you sync only specific tables or specific content types. You choose exactly what moves and what stays.
How it works
Tools like WP Migrate Pro and WP Synchro support table-level selection. Combined with WP-CLI, you can automate selective syncs as part of your WordPress CI/CD pipeline:
- Sync only
wp_optionsfor configuration changes (exclude transients and session data) - Pull only
wp_postsandwp_postmetafrom production to get fresh content for staging - Skip WooCommerce order tables entirely when syncing staging to production
- Use find-and-replace to handle URL differences between environments (staging.example.com -> example.com)
Handling the UGC problem
The trickiest scenario — and the one that came up in a recent conversation that inspired this post — is user-generated content. When your production site constantly receives new orders, form submissions, or community posts, your staging database is outdated the moment you copy it.
The answer: accept it. Staging doesn’t need to be a perfect mirror of production at all times. It needs to be close enough to test your code changes reliably. Pull production DB down to staging before each sprint or major feature. Do a one-way sync. Never push staging content back up.
For clients who need to review content changes alongside code changes on staging, set up a separate content staging workflow: they make changes on staging for review, then re-apply them on production post-deploy. Not perfect, but significantly safer than bidirectional database syncing.
When to use it
Active WooCommerce stores, membership sites, sites with heavy form submissions, any site where user data flows into the database constantly. This is also the right approach when onboarding a new project — pull the production database down to your devops setup to build WordPress site locally, then switch to Strategy 1 or 2 for ongoing work.
The tradeoff
Requires understanding which tables belong to which plugins. Getting this wrong can break relationships between posts and their meta, or between orders and their items. Always test selective syncs on a disposable copy first.
How These Strategies Work Together
In practice, most mature teams use all three strategies depending on the situation:
- Day-to-day development: Strategy 1 (production is truth for content, code deploys through pipeline)
- Feature development with DB changes: Strategy 2 (migration scripts for schema and config changes)
- Sprint kickoff or environment refresh: Strategy 3 (selective pull from production to staging/local)
This layered approach is what turns a basic WordPress devops pipeline into a reliable, enterprise-grade workflow. And it works whether you’re using GitHub Actions, Buddy Works, Bitbucket Pipelines, or DeployHQ WordPress integrations.
The Tools That Make It Work
Here’s the stack we recommend for a solid WordPress continuous deployment workflow:
- Git + CI/CD platform (GitHub Actions, Buddy Works, DeployHQ, Bitbucket Pipelines) — code deployment
- WP-CLI — command-line database operations, cache clearing, migration execution
- WP Migrations (Delicious Brains library) — versioned database migration scripts
- WP Migrate Pro or WP Synchro — selective database sync with find-replace
- ACF Local JSON — keeps field group definitions in Git instead of the database
- Proper staging environment — same PHP version, same plugins, same server config as production
If you’re setting up WordPress CI for the first time, start with Strategy 1. It solves 80% of the problem with zero tooling investment. Add migration scripts (Strategy 2) when your team grows or your project complexity increases. Use selective sync (Strategy 3) for environment refreshes and onboarding.
Stop Fighting the Database. Build a Strategy.
The WordPress database sync problem isn’t going away. WordPress will always store configuration alongside content. Plugins will always have their own storage patterns. Clients will always edit production while you’re building features on staging.
But with the right strategy — and the discipline to stick to it — database sync stops being the thing that blows up your Saturday and becomes just another part of your WordPress DevOps workflow.
We’ve built and maintained these pipelines across dozens of client projects — from content-heavy corporate sites to high-traffic WooCommerce stores. If your team is still wrestling with database sync, or if you’re setting up WordPress enterprise CI/CD for the first time, we can help.
Ready to get your WordPress deployment pipeline sorted? Book a free intro call and let’s talk about your setup.


