]> git.decadent.org.uk Git - dak.git/blobdiff - dak/update_db.py
merge from master
[dak.git] / dak / update_db.py
index d4aefe24c93b64b8404835f77e98a9cdf0c5dd85..f7d13750d9be48738ee8cb7c78d6ac4c77a28b3a 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 
-# Debian Archive Kit Database Update Script
+""" Database Update Main Script """
 # Copyright (C) 2008  Michael Casadevall <mcasadevall@debian.org>
 
 # This program is free software; you can redistribute it and/or modify
@@ -37,7 +37,7 @@ from daklib import utils
 
 Cnf = None
 projectB = None
-required_database_schema = 3
+required_database_schema = 4
 
 ################################################################################
 
@@ -53,7 +53,7 @@ Updates dak's database schema to the lastest version. You should disable crontab
 ################################################################################
 
     def update_db_to_zero(self):
-        # This function will attempt to update a pre-zero database schema to zero
+        """ This function will attempt to update a pre-zero database schema to zero """
 
         # First, do the sure thing, and create the configuration table
         try:
@@ -137,9 +137,15 @@ Updates dak's database schema to the lastest version. You should disable crontab
 
         for i in range (database_revision, required_database_schema):
             print "updating databse schema from " + str(database_revision) + " to " + str(i+1)
-            dakdb = __import__("dakdb", globals(), locals(), ['update'+str(i+1)])
-            update_module = getattr(dakdb, "update"+str(i+1))
-            update_module.do_update(self)
+            try:
+                dakdb = __import__("dakdb", globals(), locals(), ['update'+str(i+1)])
+                update_module = getattr(dakdb, "update"+str(i+1))
+                update_module.do_update(self)
+            except DBUpdateError, e:
+                # Seems the update did not work.
+                print "Was unable to update database schema from %s to %s." % (str(database_revision), str(i+1))
+                print "The error message received was %s" % (e)
+                utils.fubar("DB Schema upgrade failed")
             database_revision += 1
 
 ################################################################################