9547: Rename non-API database upgrade methods

This commit is contained in:
Nick Hall 2016-06-25 22:08:03 +01:00
parent 535ce58f17
commit 095e0e529f
4 changed files with 4 additions and 26 deletions

View File

@ -879,12 +879,6 @@ class DbReadBase:
""" """
raise NotImplementedError raise NotImplementedError
def gramps_upgrade(self):
"""
Return True if database is upgraded
"""
raise NotImplementedError
def has_event_handle(self, handle): def has_event_handle(self, handle):
""" """
Return True if the handle exists in the current Event database. Return True if the handle exists in the current Event database.
@ -1582,12 +1576,6 @@ class DbWriteBase(DbReadBase):
""" """
raise NotImplementedError raise NotImplementedError
def need_schema_upgrade(self):
"""
Return True if database needs to be upgraded
"""
raise NotImplementedError
def rebuild_secondary(self, callback): def rebuild_secondary(self, callback):
""" """
Rebuild secondary indices Rebuild secondary indices

View File

@ -122,7 +122,6 @@ class DbTest(unittest.TestCase):
"get_tag_handles", "get_tag_handles",
"get_surname_list", "get_surname_list",
"get_url_types", "get_url_types",
"gramps_upgrade",
"has_event_handle", "has_event_handle",
"has_family_handle", "has_family_handle",
"has_gramps_id", "has_gramps_id",
@ -194,7 +193,6 @@ class DbTest(unittest.TestCase):
"commit_repository", "commit_repository",
"commit_source", "commit_source",
"commit_tag", "commit_tag",
"need_schema_upgrade",
"rebuild_secondary", "rebuild_secondary",
"reindex_reference_map", "reindex_reference_map",
"remove_event", "remove_event",

View File

@ -684,7 +684,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
return ((dbversion <= _DBVERSION) and (dbversion >= _MINVERSION)) return ((dbversion <= _DBVERSION) and (dbversion >= _MINVERSION))
@catch_db_error @catch_db_error
def need_schema_upgrade(self): def _need_schema_upgrade(self):
dbversion = self.metadata.get(b'version', default=0) dbversion = self.metadata.get(b'version', default=0)
return not self.readonly and dbversion < _DBVERSION return not self.readonly and dbversion < _DBVERSION
@ -901,13 +901,13 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
self.__load_metadata() self.__load_metadata()
if self.need_schema_upgrade(): if self._need_schema_upgrade():
oldschema = self.metadata.get(b'version', default=0) oldschema = self.metadata.get(b'version', default=0)
newschema = _DBVERSION newschema = _DBVERSION
_LOG.debug("Schema upgrade required from %s to %s" % _LOG.debug("Schema upgrade required from %s to %s" %
(oldschema, newschema)) (oldschema, newschema))
if force_schema_upgrade == True: if force_schema_upgrade == True:
self.gramps_upgrade(callback) self._gramps_upgrade(callback)
versionpath = os.path.join(name, str(SCHVERSFN)) versionpath = os.path.join(name, str(SCHVERSFN))
with open(versionpath, "w") as version_file: with open(versionpath, "w") as version_file:
version = str(_DBVERSION) version = str(_DBVERSION)
@ -2335,7 +2335,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
def redo(self, update_history=True): def redo(self, update_history=True):
return self.undodb.redo(update_history) return self.undodb.redo(update_history)
def gramps_upgrade(self, callback=None): def _gramps_upgrade(self, callback=None):
UpdateCallback.__init__(self, callback) UpdateCallback.__init__(self, callback)
version = self.metadata.get(b'version', default=_MINVERSION) version = self.metadata.get(b'version', default=_MINVERSION)

View File

@ -1236,14 +1236,6 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
LOG.warn("database is closed") LOG.warn("database is closed")
return [] return []
def gramps_upgrade(self):
"""
Return True if database is upgraded
"""
if not self.db_is_open:
LOG.warn("database is closed")
return True
def has_event_handle(self, handle): def has_event_handle(self, handle):
""" """
Return True if the handle exists in the current Event database. Return True if the handle exists in the current Event database.