When you encounter a task you may often just think of what is needed to complete that task, but not how you will have to live with it. Plan ahead to ensure your decisions keep your maintenance and debugging time minimal.
Allow code to execute repeatedly, if necessary to check for various conditions. This is especially true with DB scripts. Don't just consider how a method runs as a whole, but what if you change the order of execution slightly.
Consider debugging your application. Are you able to jump up a few lines of code and re-execute without resetting your variables? If you re-use a variable for different purposes in the same area this may not be the case. Writing single-purpose methods can help eliminate this problem.
What about your DB scripts? Are they set-up so you can only run them once in a given environment? That might work OK for the initial release, but if they are re-run you may encounter problems.
Perhaps you can set up your DB scripts to first check if an object exists then delete it before creating it. Maybe you can check for some values in the table before you perform an insert or update. In some environments data can get changed just enough to require substantial debugging. Would it work better for you to just run a script and restore it to a reliable state?