How to migrate a database using git?

I do website development (mainly Drupal core sites) and do the workflow with

  • many developers working with their local machines
  • developers use git to merge their changes on the development machine
  • when the website-developer reaches a stable point, we click on the intermediate server for viewing by the client
  • and finally we do releases on the production server

And git moves files nicely back and forth. My question is how to make this one of them and use git to transfer the database along with the files?

And as soon as I can move the dev databases up the stairs, how do I combine development databases with an active production database?

+4
source share
1 answer

The easiest way to get started is to simply dump the database into a single file and store it in git, as well as in the sources. But be sure not to leak this file into production webroot, so some schema.sql not available in HTTP. It is convenient to store sources in /webroot and db in the /db subdirectories of your repository, creating the actual root /webroot web server.

Then you will see some updates and merges and even conflicts around this file - they should be resolved, as usual, in your code files.

After all the merges and conflict resolution of both the schema code and the executable code, you should carefully test the application at the end.

+1
source

All Articles