I’m working on improving my git workflow as it applies to my WordPress development projects. Often, when developing a content management system, I’ll create a development server (like http://dev.finalsitename.com
) containing the custom post types and taxonomies that will be used in the production version. This allows my client to begin adding their content to the site.
While they are working on this task, I’m usually building out the look and feel as well as the custom programming/plugins that will be used on my localhost environment. To ensure that I don’t overwrite any of their updates, I generally pull a copy of their database down and replace mine. However, there are times where I just need to hop into the WP admin area and change a setting or something else small…
If there are multiple developers working on a WordPress project, we each do a (timestamped) database dump of our version of the site and include in in the root directory before committing and pushing their local branch back to the remote repository. The trouble with this approach is that the databases are often out of sync with no easy way to determine which to use.
What are other developers doing to keep their databases in sync while still allowing multiple developers (and clients/content producers) to work on the same project?
There are 3 options from easiest –>
Use only one remote database that you all connect to with lots of backups. That way you just have to worry about files and not the db.
Use the import and export functionality built into WordPress and throw it into your version control right into the wp root (like in a new folder). Sure it takes an extra few minutes but its dead simple and you can automate it, but more importantly it will become part of the version control.
Use a custom updating script to version the actual database sync. I honestly don’t know how you can manage that with git because its a just a script and doesn’t really know what is going on, I know there are 3rd party tools that do this commercial and free ( http://www.liquibase.org/).
If you need to keep the databases in sync entirely, ie. schema and data, you might develop a custom versioning system based on backups.
Or if you want to keep the data from production but evolve its schema, you might work with a custom solution (a versioned file with all the schema changes), or with a standard solution based on the concept of
migration
. You can find a lot of info in this stackoverflow thread: Mechanisms for tracking db schema changes.I’m sorry if this seems incredibly obvious but if you all need to have the same copy of the database with the same structure, would it not make sense to have an office/central SQL server and use that? Clone it locally if you need to experiment but keep it as the authorative defacto standard and take backups of that server and only that server.
Otherwise when I’m working on a group project we have our own setups with different content. The code takes care of upgrading and migrating table structures and we can access eachothers local installations of the code running on our machines over the LAN, so there’s no need for us to share content.
If we’re entering content we run it on a test server which we can then either export and import into the live server, or we can migrate directly on to the production server if no live instance currently exists.
If at any point you need a separation of live test and WIP data, then just use a live, test, and development branch in your repository
For those that don’t find the above solutions to be easy enough a great paid plugin solution is WP Migrate DB Pro
It allows you to push and pull databases between WordPress instances. It still doesn’t offer a git like system for your databases but if you have a central staging server which is the “truth” for the databases and where things should be changed it works amazingly.
(Deprecated suggestion below – Thanks Elmar in comments)
Or you could investigate Version Press which does claim to offer a git like management of files and databases. This plugin I haven’t used however I’ve been watching it for some time and it’s still around so.