zeitgeist team mailing list archive
-
zeitgeist team
-
Mailing list archive
-
Message #02163
[Merge] lp:~seif/zeitgeist/fix-643303 into lp:zeitgeist
Seif Lotfy has proposed merging lp:~seif/zeitgeist/fix-643303 into lp:zeitgeist.
Requested reviews:
Zeitgeist Framework Team (zeitgeist)
Related bugs:
#643303 Upgrade of the db schema strategy for version jumps
https://bugs.launchpad.net/bugs/643303
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.
--
https://code.launchpad.net/~seif/zeitgeist/fix-643303/+merge/39201
Your team Zeitgeist Framework Team is requested to review the proposed merge of lp:~seif/zeitgeist/fix-643303 into lp:zeitgeist.
=== modified file '_zeitgeist/engine/sql.py'
--- _zeitgeist/engine/sql.py 2010-09-21 16:15:14 +0000
+++ _zeitgeist/engine/sql.py 2010-10-23 15:23:42 +0000
@@ -93,20 +93,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):
Follow ups