Drupal on Git, what to do with the database?

2019-03-08 11:34发布

I'm currently developing a Drupal website with a couple of people on Git; it is important that this website would be using the same database without the path because each developer has the dev version on another directory.

How should I do it?

Perhaps I should make Drupal work with SQLite on the development only; then we could add the SQLite file to the Git repository.

标签: git drupal
2条回答
Root(大扎)
2楼-- · 2019-03-08 12:12

Instead of working at the database level to store your site components, use code. Drupal has now great supports for exportables for views, content type, fields, input formats, etc. with the help of the features module.

See The Development -> Staging -> Production Workflow Problem in Drupal and the Code driven development: using Features effectively in Drupal 6 and 7 presentation.

查看更多
Luminary・发光体
3楼-- · 2019-03-08 12:37

I'm used to Django, where it's very easy to export a "fixture" (a backup) of the database and store it in a version control system like git. I was recently looking into doing this, but for WordPress. While doing so, I came across some people talking about an awesome command line tool for Drupal called drush: http://drupal.org/project/drush

This tool allows for some awesome things to be done from the command line, especially when coupled with modules like Backup and Migrate: http://drupal.org/project/backup_migrate

The basic gist is that you backup the database to an SQL dump when you're pushing/pulling to/from the server, then you can restore the DB afterward. If anything goes wrong, at least you have backup states of the DB in git. That last part is a really big feature, I think.

Here's a great article on syncing local/live sites with drush and git: https://web.archive.org/web/20131231204544/http://www.opc.com.au/web-development/drupal-release-management-drush-and-git

Here's how another user deals with including the DB in a git repo: http://drupal.org/creating-drupal-test-sites#comment-2130760

The issue here is that you'll have to be careful about syncing the DB back to the live site. It's easy and simple to have multiple people grab the latest version of the live DB for testing purposes, but it could be dangerous to push someone's local version of the DB back to production (but only if multiple people are on the same project).

Just for curiosity's sake, here's a similar question I asked on the WordPress StackExchange site: https://wordpress.stackexchange.com/questions/12239/migrating-data-between-local-and-development-server — I then asked (and answered) a more specific version of the question here: https://wordpress.stackexchange.com/questions/12719/multiple-developers-editors-working-on-a-site-in-progress

查看更多
登录 后发表回答