Merge lp:~seif/zeitgeist/fix-665607-and-643303 into lp:zeitgeist/0.1

Proposed by Seif Lotfy
Status: Merged
Merged at revision: 1624
Proposed branch: lp:~seif/zeitgeist/fix-665607-and-643303
Merge into: lp:zeitgeist/0.1
Diff against target: 46 lines (+14/-14)
1 file modified
_zeitgeist/engine/sql.py (+14/-14)
To merge this branch: bzr merge lp:~seif/zeitgeist/fix-665607-and-643303
Reviewer Review Type Date Requested Status
Siegfried Gevatter Approve
Review via email: mp+39307@code.launchpad.net

Description of the change

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

To post a comment you must log in.
Revision history for this message
Siegfried Gevatter (rainct) wrote :

From the previous merge proposal:

My comment:
 > Looks good to me. Mikkel, Markus, do you agree this is the
 > approach with which we want to handle database upgrades?

Markus' comment:
 > okidoki, my take on this: I would like to have some kind of tests
 > for the upgrade pathes, but please let's not do it like Seif tried
 > in rev 1625.
 > Therefor I suggest the following, let's merge this branch without
 > rev 1625 into lp:zeitgeist, and then put some work into writing a
 > testing framework for db schemes and upgrades.

review: Approve
1626. By Seif Lotfy

cleanup zeitgeist-daemon and log prints

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '_zeitgeist/engine/sql.py'
2--- _zeitgeist/engine/sql.py 2010-10-19 13:54:12 +0000
3+++ _zeitgeist/engine/sql.py 2010-10-25 20:29:44 +0000
4@@ -92,20 +92,20 @@
5 def _do_schema_upgrade (cursor, schema_name, old_version, new_version):
6 """
7 Try and upgrade schema `schema_name` from version `old_version` to
8- `new_version`. This is done by checking for an upgrade module named
9- '_zeitgeist.engine.upgrades.$schema_name_$old_version_$new_version'
10- and executing the run(cursor) method of that module
11+ `new_version`. This is done by executing a series of upgrade modules
12+ named '_zeitgeist.engine.upgrades.$schema_name_$(i)_$(i+1)' and executing
13+ the run(cursor) method of those modules until new_version is reached
14 """
15- # Fire of the right upgrade module
16- log.info("Upgrading database '%s' from version %s to %s. This may take a while" %
17- (schema_name, old_version, new_version))
18- upgrader_name = "%s_%s_%s" % (schema_name, old_version, new_version)
19- module = __import__ ("_zeitgeist.engine.upgrades.%s" % upgrader_name)
20- eval("module.engine.upgrades.%s.run(cursor)" % upgrader_name)
21-
22- # Update the schema version
23- _set_schema_version(cursor, schema_name, new_version)
24-
25+ for i in xrange(old_version, new_version):
26+ # Fire of the right upgrade module
27+ log.info("Upgrading database '%s' from version %s to %s. This may take a while" %
28+ (schema_name, i, i+1))
29+ upgrader_name = "%s_%s_%s" % (schema_name, i, i+1)
30+ module = __import__ ("_zeitgeist.engine.upgrades.%s" % upgrader_name)
31+ eval("module.engine.upgrades.%s.run(cursor)" % upgrader_name)
32+
33+ # Update the schema version
34+ _set_schema_version(cursor, schema_name, i+1)
35 log.info("Upgrade succesful")
36
37 def _check_core_schema_upgrade (cursor):
38@@ -113,7 +113,7 @@
39 # See if we have the right schema version, and try an upgrade if needed
40 core_schema_version = _get_schema_version(cursor, constants.CORE_SCHEMA)
41 if core_schema_version is not None:
42- if core_schema_version == constants.CORE_SCHEMA_VERSION:
43+ if core_schema_version >= constants.CORE_SCHEMA_VERSION:
44 return True
45 else:
46 try:

Subscribers

People subscribed via source and target branches