Reputation: 111
I have 2 environments for WordPress (dev && production), I'm working on dev env, when I add some new plugins, some will create tables or update configs in DB, how can I handle all these changes and then migrate to production env's DB?
I'm using git for file changes, but I can't handle the DB changes which created by plugins. How to integrate these changes in git? Or other workarounds?
I'm using a WordPress docker image, and I mounted an existing folder to /var/www/html
I upload the mounted folder to git for version control.
Except to manage all changes in version control tool.
Update:
I'm using wordpress 5.2.2.
How can I put a database under git (version control)? This one is the same. But looks like a little difference.
As this answer says, keep both data dump and schema dump. Is data dump have a correct diff info with previous? So that I can manually add this change to something like liquibase
's changeset?
My concern is just the DB changes which changed by 3rd-part plugin, and I will hardly to trace.
Upvotes: 2
Views: 369
Reputation: 13638
Here's is what we do. Any proper plug in will initialize new DB tables/fields on activation, and remove DB tables/fields when the plug-in is deactivated. In this way the plug in itself handles all DB migration functions. We write our plugins in this way, and nearly all plug-ins work in a similar fashion. We just commit plugin code to git, test in Dev, then release to production, and activate. Boom database is migrated. Nearly all database changes are driven by new plugins installation. Let it manage the database via it's own activate /deactivate hooks.
Upvotes: 2