From 75bf103429de768004d7b043757ccf91ff26f4b7 Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Wed, 7 Mar 2018 15:52:12 +0000 Subject: [PATCH] Create _schema_exists method --- gramps/gen/db/generic.py | 4 +--- gramps/plugins/db/dbapi/dbapi.py | 9 +++++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/gramps/gen/db/generic.py b/gramps/gen/db/generic.py index 023e413d4..9f4b2cf5e 100644 --- a/gramps/gen/db/generic.py +++ b/gramps/gen/db/generic.py @@ -625,9 +625,7 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback): # run backend-specific code: self._initialize(directory, username, password) - # We use the existence of the person table as a proxy for the database - # being new - if not self.dbapi.table_exists("person"): + if not self._schema_exists(): self._create_schema() self._set_metadata('version', str(self.VERSION[0])) diff --git a/gramps/plugins/db/dbapi/dbapi.py b/gramps/plugins/db/dbapi/dbapi.py index 425f5c7aa..72ff08c99 100644 --- a/gramps/plugins/db/dbapi/dbapi.py +++ b/gramps/plugins/db/dbapi/dbapi.py @@ -56,6 +56,15 @@ class DBAPI(DbGeneric): def _initialize(self, directory, username, password): raise NotImplementedError + def _schema_exists(self): + """ + Check to see if the schema exists. + + We use the existence of the person table as a proxy for the database + being new. + """ + return self.dbapi.table_exists("person") + def _create_schema(self): """ Create and update schema.