Create _schema_exists method

This commit is contained in:
Nick Hall 2018-03-07 15:52:12 +00:00
parent cf42e5a4b8
commit 75bf103429
2 changed files with 10 additions and 3 deletions

View File

@ -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]))

View File

@ -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.