- print "dak database schema at " + str(database_revision)
- print "dak version requires schema " + str(required_database_schema)
-
- if database_revision == required_database_schema:
+ dbfiles = glob(os.path.join(os.path.dirname(__file__), 'dakdb/update*.py'))
+ required_database_schema = max(map(int, findall('update(\d+).py', " ".join(dbfiles))))
+
+ print "dak database schema at %d" % database_revision
+ print "dak version requires schema %d" % required_database_schema
+
+ if database_revision < required_database_schema:
+ print "\nUpdates to be applied:"
+ for i in range(database_revision, required_database_schema):
+ i += 1
+ dakdb = __import__("dakdb", globals(), locals(), ['update'+str(i)])
+ update_module = getattr(dakdb, "update"+str(i))
+ print "Update %d: %s" % (i, next(s for s in update_module.__doc__.split("\n") if s))
+ modules.append((update_module, i))
+ prompt = "\nUpdate database? (y/N) "
+ answer = utils.our_raw_input(prompt)
+ if answer.upper() != 'Y':
+ sys.exit(0)
+ else: