# HG changeset patch # User Daniele Nicolodi # Date 1309174912 -7200 # Node ID fad020eceac0032c2ca039d26ff72a77cf14c54e # Parent 9883a35f89f34b3fc80f9b560a540c8c05a9e484 Add support for forcing initial schema version in upgrades. diff -r 9883a35f89f3 -r fad020eceac0 src/ltpdarepo/upgrade.py --- a/src/ltpdarepo/upgrade.py Sat Jun 25 17:55:21 2011 +0200 +++ b/src/ltpdarepo/upgrade.py Mon Jun 27 13:41:52 2011 +0200 @@ -19,15 +19,17 @@ return func -def upgrade(): - conn = db.connect(host=HOSTNAME, db=DATABASE, - user=USERNAME, passwd=PASSWORD) +def upgrade(fromrev=None): + conn = db.connect(host=HOSTNAME, db=DATABASE, user=USERNAME, passwd=PASSWORD) curs = conn.cursor() # current schema version curs.execute("""SELECT value+0 FROM options WHERE name='version'""") schema = curs.fetchone()[0] + if fromrev is not None: + schema = fromrev + # filter applicable upgrade steps todo = filter(lambda x: x[0] >= schema, steps)