Seif Lotfy has proposed merging lp:~seif/zeitgeist/fix-665607-and-643303 into 
lp:zeitgeist.

Requested reviews:
  Zeitgeist Framework Team (zeitgeist)


I tried to fix the bug by simple detecting the current core schema and "i" and 
then iterating through all update scripts in form of 'core_"i"_"i+1"' its 
simple and straight forward. No looking for paths and leaving us to actually 
only worry about upgrade +1 increasing upgrade scripts. If the basic idea is OK 
I can propose for merging.

Bugs fixed: #665607 and #643303

-- 
https://code.launchpad.net/~seif/zeitgeist/fix-665607-and-643303/+merge/39307
Your team Zeitgeist Framework Team is requested to review the proposed merge of 
lp:~seif/zeitgeist/fix-665607-and-643303 into lp:zeitgeist.
=== modified file '_zeitgeist/engine/sql.py'
--- _zeitgeist/engine/sql.py	2010-10-19 13:54:12 +0000
+++ _zeitgeist/engine/sql.py	2010-10-25 20:11:11 +0000
@@ -92,20 +92,20 @@
 def _do_schema_upgrade (cursor, schema_name, old_version, new_version):
 	"""
 	Try and upgrade schema `schema_name` from version `old_version` to
-	`new_version`. This is done by checking for an upgrade module named
-	'_zeitgeist.engine.upgrades.$schema_name_$old_version_$new_version'
-	and executing the run(cursor) method of that module
+	`new_version`. This is done by executing a series of upgrade modules
+	named '_zeitgeist.engine.upgrades.$schema_name_$(i)_$(i+1)' and executing 
+	the run(cursor) method of those modules until new_version is reached
 	"""
-	# Fire of the right upgrade module
-	log.info("Upgrading database '%s' from version %s to %s. This may take a while" %
-	         (schema_name, old_version, new_version))
-	upgrader_name = "%s_%s_%s" % (schema_name, old_version, new_version)
-	module = __import__ ("_zeitgeist.engine.upgrades.%s" % upgrader_name)
-	eval("module.engine.upgrades.%s.run(cursor)" % upgrader_name)
-	
-	# Update the schema version
-	_set_schema_version(cursor, schema_name, new_version)
-	
+	for i in xrange(old_version, new_version):
+		# Fire of the right upgrade module
+		log.info("Upgrading database '%s' from version %s to %s. This may take a while" %
+		         (schema_name, i, i+1))
+		upgrader_name = "%s_%s_%s" % (schema_name, i, i+1)
+		module = __import__ ("_zeitgeist.engine.upgrades.%s" % upgrader_name)
+		eval("module.engine.upgrades.%s.run(cursor)" % upgrader_name)
+		
+		# Update the schema version
+		_set_schema_version(cursor, schema_name, i+1)
 	log.info("Upgrade succesful")
 
 def _check_core_schema_upgrade (cursor):
@@ -113,7 +113,7 @@
 	# See if we have the right schema version, and try an upgrade if needed
 	core_schema_version = _get_schema_version(cursor, constants.CORE_SCHEMA)
 	if core_schema_version is not None:
-		if core_schema_version == constants.CORE_SCHEMA_VERSION:
+		if core_schema_version >= constants.CORE_SCHEMA_VERSION:
 			return True
 		else:
 			try:

_______________________________________________
Mailing list: https://launchpad.net/~zeitgeist
Post to     : zeitgeist@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zeitgeist
More help   : https://help.launchpad.net/ListHelp

Reply via email to