fedeisas
fedeisas

Reputation: 2023

Drupal deployment: how to handle Database?

I've spend two days reading questions on SO, blog posts, forums, etc.

Most of that information, it's old.

I'm building a site on my Ubuntu box using Drupal 7 (with Drush) and GitHub for repo hosting. I have SSH access to the production server.

After I deliver the first version of the site, I'm gonna have to add features and fix bugs.

A friend told me to store my SQL file on the repo, and go from there.

My question is: what's the best approach? Is there a good practice advise about this?

Thanks!

Upvotes: 1

Views: 761

Answers (2)

Grayside
Grayside

Reputation: 4194

Deployment in Drupal is a complex subject, because Drupal itself doesn't have a good answer for the general topic of configuration management. A major initiative has made significant progress for Drupal 8 to get it there, but for now, we deal with the awkwardness of content and configuration both stored in the database.

At bare minimum, you will need the database dump for content. From there, it becomes an entire series of potential essays. Just to touch on a few:

  • Using update hooks in a module to manage database changes as part of your deployment workflow.
  • Using exportables/everything-in-code approach, in which the configuration-type bits of the database are exported as PHP code as part of site-custom modules. Too many different ways to do this for me to find a good page to link to, but we use the Features module.
  • Using drush as a wrapper around rsync so you can manage deployments and data transfers using tools like site aliases. Drush is an awesome tool, just keep digging into it.

You can dump your SQL into the repository, but we don't find it necessary since all configuration we care to version is exported to code. So the SQL dump really amounts to a backup.

Upvotes: 0

EricMinick
EricMinick

Reputation: 1487

I'm not a Drupal expert, but in general database deployments are tricky - especially if you end up with test and prod environments because changes end up needing to be ordered. I recommend using some form of "master script" that executes the database updates you need. We wrap ours with queries that ask the database what version are you on, and applies only new sql updates.

Upvotes: 1

Related Questions