1

I am the sole developer on a Drupal 7 site, and I need advice. I use Git, having a 'master' branch (the published version of the site) and a 'dev' branch (the experimental features for future versions of the site).

Using Capistrano for deployment, I've gotten it fairly easy to deploy the two branches to their respective URLs, but I'm up against this wall where I'm not sure how to merge the 'dev' branch database into the 'master' branch after the new features are ready for production.

With a lot of Drupal's structure stored in the database, like Content Types and Views, what solutions are there for merging database changes from the 'dev' branch's url to the 'master' branch's url? So far, I've been writing down the changes I make and then recreating them on the production site before I merge the dev branch back into the master branch.

4
  • I have struggled with this same question...best I can determine is to use a SQL migration tool to at least see if any schema changes have occurred. I try and keep both copies sync'ed daily to avoid issues like this. Commented Jan 30, 2014 at 19:29
  • It makes me feel better to know that I'm not the only one struggling with this... whew Commented Jan 30, 2014 at 19:33
  • Drupal is really neat in many ways but a great deal of confusion and frustration in others...I don't think anyone is alone in that regard :) Commented Jan 30, 2014 at 19:35
  • It's really quite a feat of engineering that Drupal is able to achieve such a level of customization for people who cannot program. Commented Jan 30, 2014 at 21:52

1 Answer 1

1

You cannot reliably 'merge' database copies. One way or another, everything has to be managed through code.

In Drupal 8 this is handled with the Configuration Initiative, but in D6 and D7 you have to use a tool like the Features module, which provides an interface to create 'features' (which are really exportable content stored in specific modules). You can export things like site configuration, content types, views, etc. into a feature, then push the code from one branch to another, and have that feature's changes "apply" on to the new database.

The Features module has its share of problems, but it does work fairly well for the most part, and is the go-to solution for managing database changes.

In addition to Features, you'll likely also want Strongarm, which lets you use Features to export data from the variables database table.

Alternatively, many people use update hooks to handle their database changes; that's a bit more involved and requires a strong understanding of Drupal development.

You may also want to read through these resources:

1
  • It sounds like "Features" is what I need; the problem I've been having is that the client will update content on the live site while I'm developing new views or such and then I can't just dump the database back in because it would revert all of the client's changes. Commented Jan 30, 2014 at 21:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.