How to migrate database with git?

I do website development (primarily Drupal base sites) and have a workflow with:

  1. many developers working on their Local machines
  2. developers use git to merge their changes on a Development machine
  3. when the dev site hits a stable point, we push to a Staging server for the client to review
  4. and finally we make releases to the Production server

And git is moving the files nicely back and forth. My question is how do I one-up this and use git to migrate the database along with the files?

  • Testing and Managing database versions against code versions
  • Versioning SQL Server database
  • What are the best practices for database scripts under code control
  • Does any database support revision control on its command line interface?
  • Can I apply version control system to database data?
  • Is there a database with git-like qualities?
  • And once I am able to move dev databases up the ladder, how do I merge development databases with the active production database?

  • Creating a remote inside a directory of remotes
  • How can I manage Linux settings (config) files in different directories in a single Git repo in another directory?
  • Missing git support, install posh-git with 'Install-Module posh-git' and restart cmder
  • Git username incorrect in git bash
  • How do I Uncommit changes using git
  • Splitting huge git repo
  • One Solution collect form web for “How to migrate database with git?”

    Most straightforward thing to start with is to just dump the database into one file and store it in the git as well as the sources. But be sure not to leak this file into the production webroot, so that some schema.sql is not easily available by HTTP. It’s convenient to store sources at /webroot and db at /db subdirectories of your repository, making the /webroot actual root of web server.

    You’ll then see some updates and merges, and even conflicts around this file — these should be resolved as usual you do to your code files.

    After all merges and conflict resolutions of both schema code and executable code you should thoroughly test your application end-to-end.

    Git Baby is a git and github fan, let's start git clone.