Index: roundup/backends/rdbms_common.py =================================================================== --- roundup/backends/rdbms_common.py (revision 4385) +++ roundup/backends/rdbms_common.py (working copy) @@ -204,8 +204,11 @@ We should now confirm that the schema defined by our "classes" attribute actually matches the schema in the database. """ - save = 0 + # upgrade the database for column type changes, new internal + # tables, etc. + save = self.upgrade_db() + # handle changes in the schema tables = self.database_schema['tables'] for classname, spec in self.classes.items(): @@ -225,10 +228,6 @@ del tables[classname] save = 1 - # now upgrade the database for column type changes, new internal - # tables, etc. - save = save | self.upgrade_db() - # update the database version of the schema if save: self.save_dbschema() @@ -275,9 +274,11 @@ self.fix_version_2_tables() if version < 4: + self.log_info('upgrade to version 4') self.fix_version_3_tables() if version < 5: + self.log_info('upgrade to version 5') self.fix_version_4_tables() self.database_schema['version'] = self.current_db_version @@ -574,7 +575,12 @@ def add_class_key_required_unique_constraint(self, cn, key): sql = '''create unique index _%s_key_retired_idx on _%s(__retired__, _%s)'''%(cn, cn, key) - self.sql(sql) + try: + self.sql(sql) + except StandardError: + # XXX catch e.g.: + # _sqlite.DatabaseError: index _status_key_retired_idx already exists + pass def drop_class_table_indexes(self, cn, key): # drop the old table indexes first Index: roundup/backends/back_sqlite.py =================================================================== --- roundup/backends/back_sqlite.py (revision 4385) +++ roundup/backends/back_sqlite.py (working copy) @@ -255,7 +255,7 @@ self.create_class_table(spec) if olddata: - inscols = ['id', '_actor', '_activity', '_creation', '_creator'] + inscols = ['id', '_actor', '_activity', '_creation', '_creator', '__retired__'] for propname,x in new_spec[1]: prop = properties[propname] if isinstance(prop, hyperdb.Multilink): @@ -274,6 +274,7 @@ sql = 'insert into _%s (%s) values (%s)'%(cn, cols, args) for entry in olddata: d = [] + retired_id = None for name in inscols: # generate the new value for the Interval int column if name.endswith('_int__'): @@ -296,6 +297,10 @@ v = entry[name] else: v = None + if name == 'id': + retired_id = v + elif name == '__retired__' and retired_id and v not in ['0', 0]: + v = retired_id d.append(v) self.sql(sql, tuple(d))