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
=== 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:29:44 +0000
@@ -92,20 +92,20 @@
92def _do_schema_upgrade (cursor, schema_name, old_version, new_version):92def _do_schema_upgrade (cursor, schema_name, old_version, new_version):
93 """93 """
94 Try and upgrade schema `schema_name` from version `old_version` to94 Try and upgrade schema `schema_name` from version `old_version` to
95 `new_version`. This is done by checking for an upgrade module named95 `new_version`. This is done by executing a series of upgrade modules
96 '_zeitgeist.engine.upgrades.$schema_name_$old_version_$new_version'96 named '_zeitgeist.engine.upgrades.$schema_name_$(i)_$(i+1)' and executing
97 and executing the run(cursor) method of that module97 the run(cursor) method of those modules until new_version is reached
98 """98 """
99 # Fire of the right upgrade module99 for i in xrange(old_version, new_version):
100 log.info("Upgrading database '%s' from version %s to %s. This may take a while" %100 # Fire of the right upgrade module
101 (schema_name, old_version, new_version))101 log.info("Upgrading database '%s' from version %s to %s. This may take a while" %
102 upgrader_name = "%s_%s_%s" % (schema_name, old_version, new_version)102 (schema_name, i, i+1))
103 module = __import__ ("_zeitgeist.engine.upgrades.%s" % upgrader_name)103 upgrader_name = "%s_%s_%s" % (schema_name, i, i+1)
104 eval("module.engine.upgrades.%s.run(cursor)" % upgrader_name)104 module = __import__ ("_zeitgeist.engine.upgrades.%s" % upgrader_name)
105 105 eval("module.engine.upgrades.%s.run(cursor)" % upgrader_name)
106 # Update the schema version106
107 _set_schema_version(cursor, schema_name, new_version)107 # Update the schema version
108 108 _set_schema_version(cursor, schema_name, i+1)
109 log.info("Upgrade succesful")109 log.info("Upgrade succesful")
110110
111def _check_core_schema_upgrade (cursor):111def _check_core_schema_upgrade (cursor):
@@ -113,7 +113,7 @@
113 # See if we have the right schema version, and try an upgrade if needed113 # See if we have the right schema version, and try an upgrade if needed
114 core_schema_version = _get_schema_version(cursor, constants.CORE_SCHEMA)114 core_schema_version = _get_schema_version(cursor, constants.CORE_SCHEMA)
115 if core_schema_version is not None:115 if core_schema_version is not None:
116 if core_schema_version == constants.CORE_SCHEMA_VERSION:116 if core_schema_version >= constants.CORE_SCHEMA_VERSION:
117 return True117 return True
118 else:118 else:
119 try:119 try:

Subscribers

People subscribed via source and target branches