Upgrading database scheme is broken for newly created databases

Bug #642898 reported by Markus Korn
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Zeitgeist Framework
Fix Released
Critical
Markus Korn

Bug Description

Todays newly created database version 2 broke the upgrade path, we have no upgrade script for 0 (which means 'no version entry found') to 2. This happens because no-existing databases do not have such table.

$ ZEITGEIST_DATABASE_PATH=/tmp/dfgdsfsddf ./zeitgeist-daemon :(
DEBUG:root:Checking for another running instance...
DEBUG:root:No running instances found.
INFO:zeitgeist.sql:Using database: /tmp/dfgdsfsddf
DEBUG:zeitgeist.sql:Schema 'core' not found: no such table: schema_version
INFO:zeitgeist.sql:Upgrading database 'core' from version 0 to 2. This may take a while
CRITICAL:zeitgeist.sql:Failed to upgrade database 'core' from version 0 to 2: No module named core_0_2

We have to check if we are operating on a new database.
(Side note: we need tests for upgrades....)

Related branches

Markus Korn (thekorn)
Changed in zeitgeist:
status: New → In Progress
importance: Undecided → Critical
assignee: nobody → Markus Korn (thekorn)
Revision history for this message
Markus Korn (thekorn) wrote :

There are two possible solutions for this issue:
1.) check if we are operating on an empty database
2.) change our upgrade function in a way that if a upgrade script is not found for X -> Z it tries to run X -> Y -> Z

For 1.) there are two possible ways:
1.a.) check if file already exists before sqlite3.connect() to this file
1.b.) change _get_schema_version() to return -1 if SQLITE_MASTER is empty

I vote for 1.a.) as a fix for this bug, and work on 2.) for the future.

Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote : Re: [Zeitgeist] [Bug 642898] Re: Upgrading database scheme is broken for newly created databases

+1 for 1.a)

Revision history for this message
Markus Korn (thekorn) wrote :

------------------------------------------------------------
revno: 1595
fixes bug(s): https://launchpad.net/bugs/642898
committer: Markus Korn <email address hidden>
branch nick: trunk
timestamp: Mon 2010-09-20 09:29:32 +0200
message:
  always create core schema for new databases (LP: #642898)
------------------------------------------------------------

Changed in zeitgeist:
status: In Progress → Fix Committed
Revision history for this message
Siegfried Gevatter (rainct) wrote :

I am closing this since the affected code was never released.

Changed in zeitgeist:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.