Drupal update scripts are a great way of automating database updates. They are extremely important to contributed modules when changing the database schema and updating existing data to the new schema. Specifically I will be discussing using update scripts in your custom modules as part of deploying new features. I'm not saying update scripts should replace using the Features module, in fact I use them together, update scripts are great for things that might not be managed in features. This will be the first in a two-part series that will cover using Drupal update scripts.
First off, the top complaints I've seen about having to write update scripts are:
It takes longer to write the script then it does to do it manually in the browser
This argument is actually true, but I'll tell you why it doesn't matter.
There isn't an easy way to do X
There are some things that aren't as simple as calling a function or two, and sometimes require you to call some internal functions or writing a helper function. This shouldn't be an excuse not to write update scripts. While I've been developing website for a lot longer, I'm still fairly new to Drupal. I attribute my fast growth in Drupal to 1) my amazing co-workers and 2) writing update scripts. Writing update scripts forces you to learn some of the Drupal internals, which helps you learn and retain that knowledge. Between Google and the Drupal API site you can learn of better and easier ways of doing things.
Learn to do it later, just want to get this done
I heard the "do it quick-and-dirty now and go back and do it right later" excuse a lot at my previous job. Not only does "later" never happen, but it was a real drain to my motivation and job satisfaction. Most people like to take pride in their work and in doing a good job, and I don't think anybody can describe 'quick-and-dirty' as doing a good job. Metal Toad holds high standards for quality, and so it is much easier to get the time to do things the right way. Obviously there are some times when you need to get something done to meet a deadline or fix a critical issue, but the bottom line is don't push it off. In fact, I would say that if you have to do something that is less then ideal to meet a deadline, you should do that and immediately schedule time to look into a more ideal solution.
In my next post I will give real examples of update scripts I've used in projects. Is there something you needed to do, but didn't know how to do in an update script? Let me know and I will try and include it in my next post of examples.