Skip to content

Commit 06d2b0b

Browse files
committed
Fixed issue2550595: Allow migrating from roundup 0.x to 1.4
All changes were required to make an upgrade from 0.6 to 1.4, The changes affecting "retired" were required for an upgrade from 0.8 to 1.4.
1 parent 0690757 commit 06d2b0b

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Fixed:
3939
where demo.py listens. (John Rouillard)
4040
- issue2550802: Fixed date so second fraction can't cause rounding to
4141
60.000 when serialising. Report and fix by Erik Hanspers. (Bernhard Reiter)
42+
- issue2550595: Allow migrating from roundup 0.x to 1.4 (Thomas Arendsen Hein)
4243

4344
2012-12-21: 1.4.21
4445

roundup/backends/back_sqlite.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def update_class(self, spec, old_spec, force=0, adding_v2=0):
254254
self.create_class_table(spec)
255255

256256
if olddata:
257-
inscols = ['id', '_actor', '_activity', '_creation', '_creator']
257+
inscols = ['id', '_actor', '_activity', '_creation', '_creator', '__retired__']
258258
for propname,x in new_spec[1]:
259259
prop = properties[propname]
260260
if isinstance(prop, hyperdb.Multilink):
@@ -273,6 +273,7 @@ def update_class(self, spec, old_spec, force=0, adding_v2=0):
273273
sql = 'insert into _%s (%s) values (%s)'%(cn, cols, args)
274274
for entry in olddata:
275275
d = []
276+
retired_id = None
276277
for name in inscols:
277278
# generate the new value for the Interval int column
278279
if name.endswith('_int__'):
@@ -295,6 +296,10 @@ def update_class(self, spec, old_spec, force=0, adding_v2=0):
295296
v = entry[name]
296297
else:
297298
v = None
299+
if name == 'id':
300+
retired_id = v
301+
elif name == '__retired__' and retired_id and v not in ['0', 0]:
302+
v = retired_id
298303
d.append(v)
299304
self.sql(sql, tuple(d))
300305

roundup/backends/rdbms_common.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,10 @@ def post_init(self):
274274
We should now confirm that the schema defined by our "classes"
275275
attribute actually matches the schema in the database.
276276
"""
277-
save = 0
277+
278+
# upgrade the database for column type changes, new internal
279+
# tables, etc.
280+
save = self.upgrade_db()
278281

279282
# handle changes in the schema
280283
tables = self.database_schema['tables']
@@ -295,10 +298,6 @@ def post_init(self):
295298
del tables[classname]
296299
save = 1
297300

298-
# now upgrade the database for column type changes, new internal
299-
# tables, etc.
300-
save = save | self.upgrade_db()
301-
302301
# update the database version of the schema
303302
if save:
304303
self.save_dbschema()
@@ -345,9 +344,11 @@ def upgrade_db(self):
345344
self.fix_version_2_tables()
346345

347346
if version < 4:
347+
self.log_info('upgrade to version 4')
348348
self.fix_version_3_tables()
349349

350350
if version < 5:
351+
self.log_info('upgrade to version 5')
351352
self.fix_version_4_tables()
352353

353354
self.database_schema['version'] = self.current_db_version
@@ -645,7 +646,12 @@ def create_class_table_indexes(self, spec):
645646
def add_class_key_required_unique_constraint(self, cn, key):
646647
sql = '''create unique index _%s_key_retired_idx
647648
on _%s(__retired__, _%s)'''%(cn, cn, key)
648-
self.sql(sql)
649+
try:
650+
self.sql(sql)
651+
except StandardError:
652+
# XXX catch e.g.:
653+
# _sqlite.DatabaseError: index _status_key_retired_idx already exists
654+
pass
649655

650656
def drop_class_table_indexes(self, cn, key):
651657
# drop the old table indexes first

0 commit comments

Comments
 (0)