comparison roundup/backends/back_sqlite.py @ 4774:3adff0fb0207

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.
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 22 Mar 2013 15:53:27 +0100
parents 67bef70ab9b9
children e424987d294a
comparison
equal deleted inserted replaced
4773:8ab5d7d63191 4774:3adff0fb0207
252 252
253 # create the new table 253 # create the new table
254 self.create_class_table(spec) 254 self.create_class_table(spec)
255 255
256 if olddata: 256 if olddata:
257 inscols = ['id', '_actor', '_activity', '_creation', '_creator'] 257 inscols = ['id', '_actor', '_activity', '_creation', '_creator', '__retired__']
258 for propname,x in new_spec[1]: 258 for propname,x in new_spec[1]:
259 prop = properties[propname] 259 prop = properties[propname]
260 if isinstance(prop, hyperdb.Multilink): 260 if isinstance(prop, hyperdb.Multilink):
261 continue 261 continue
262 elif isinstance(prop, hyperdb.Interval): 262 elif isinstance(prop, hyperdb.Interval):
271 args = ','.join([self.arg for x in inscols]) 271 args = ','.join([self.arg for x in inscols])
272 cols = ','.join(inscols) 272 cols = ','.join(inscols)
273 sql = 'insert into _%s (%s) values (%s)'%(cn, cols, args) 273 sql = 'insert into _%s (%s) values (%s)'%(cn, cols, args)
274 for entry in olddata: 274 for entry in olddata:
275 d = [] 275 d = []
276 retired_id = None
276 for name in inscols: 277 for name in inscols:
277 # generate the new value for the Interval int column 278 # generate the new value for the Interval int column
278 if name.endswith('_int__'): 279 if name.endswith('_int__'):
279 name = name[2:-6] 280 name = name[2:-6]
280 if sqlite_version in (2,3): 281 if sqlite_version in (2,3):
293 v = None 294 v = None
294 elif (sqlite_version == 1 and name in entry): 295 elif (sqlite_version == 1 and name in entry):
295 v = entry[name] 296 v = entry[name]
296 else: 297 else:
297 v = None 298 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
298 d.append(v) 303 d.append(v)
299 self.sql(sql, tuple(d)) 304 self.sql(sql, tuple(d))
300 305
301 return 1 306 return 1
302 307

Roundup Issue Tracker: http://roundup-tracker.org/