From a25c241b8ec7e380397cef4cf815ea055f9cd0b6 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Wed, 18 Jan 2006 22:02:24 +0000 Subject: [PATCH] * src/GrampsDb/_GrampsBSDDB.py: upgrade from gramps20. svn: r5790 --- ChangeLog | 1 + src/GrampsDb/_GrampsBSDDB.py | 24 +++++++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9e560a701..7cb729976 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,7 @@ * src/GrampsDb/_ReadGedcom.py (parse_record): Restore add def_src. * src/GrampsDb/_GrampsBSDDB.py (rebuild_secondary): Proper rebuild; convert surnames secondary index to DUPSORTed BTREE. + * src/GrampsDb/_GrampsBSDDB.py: upgrade from gramps20. 2006-01-17 Don Allingham * src/DbPrompter.py: removed diff --git a/src/GrampsDb/_GrampsBSDDB.py b/src/GrampsDb/_GrampsBSDDB.py index a483afe2e..30a7c6e99 100644 --- a/src/GrampsDb/_GrampsBSDDB.py +++ b/src/GrampsDb/_GrampsBSDDB.py @@ -292,10 +292,21 @@ class GrampsBSDDB(GrampsDbBase): else: table_flags = db.DB_CREATE|db.DB_AUTO_COMMIT - self.surnames = db.DB(self.env) - self.surnames.set_flags(db.DB_DUP|db.DB_DUPSORT) - self.surnames.open(self.full_name, "surnames", - db.DB_BTREE, flags=table_flags) + # Try to upgrade from gramps20 + # that had HASH for surnames table + try: + self.surnames = db.DB(self.env) + self.surnames.set_flags(db.DB_DUP|db.DB_DUPSORT) + self.surnames.open(self.full_name, "surnames", + db.DB_BTREE, flags=table_flags) + except db.DBInvalidArgError: + self.surnames.close() + junk = db.DB(self.env) + junk.remove(self.full_name,"surnames") + self.surnames = db.DB(self.env) + self.surnames.set_flags(db.DB_DUP|db.DB_DUPSORT) + self.surnames.open(self.full_name, "surnames", db.DB_BTREE, + flags=table_flags) self.name_group = db.DB(self.env) self.name_group.set_flags(db.DB_DUP) @@ -1200,9 +1211,8 @@ class GrampsBSDDB(GrampsDbBase): pass # The rest of the upgrade deals with real data, not metadata - # so starting transaction here. - trans = Transaction("",self) - trans.set_batch(True) + # so starting (batch) transaction here. + trans = self.transaction_begin("",True) # This upgrade adds marker to every primary object. # We need to extract and commit every primary object