X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fupdate_db.py;h=5fe6918ab3bae19e9875f2aed1c4716540547e61;hb=b612f3da207fa0d75a5d3b204ac8f02bb244231a;hp=f9b6e478fd6686ecde9d3b15f56b8f61ded2a645;hpb=0d80b258098ff470433efa4d9c1f81b404883195;p=dak.git diff --git a/dak/update_db.py b/dak/update_db.py index f9b6e478..5fe6918a 100755 --- a/dak/update_db.py +++ b/dak/update_db.py @@ -1,7 +1,11 @@ #!/usr/bin/env python -""" Database Update Main Script """ +""" Database Update Main Script + +@contact: Debian FTP Master # Copyright (C) 2008 Michael Casadevall +@license: GNU General Public License version 2 or later +""" # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -26,18 +30,22 @@ ################################################################################ -import psycopg2, sys, fcntl, os +import psycopg2 +import sys +import fcntl +import os import apt_pkg import time import errno from daklib import database from daklib import utils +from daklib.dak_exceptions import DBUpdateError ################################################################################ Cnf = None projectB = None -required_database_schema = 3 +required_database_schema = 13 ################################################################################ @@ -136,10 +144,16 @@ Updates dak's database schema to the lastest version. You should disable crontab sys.exit(0) 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) + print "updating database schema from " + str(database_revision) + " to " + str(i+1) + 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 ################################################################################