Skip to content

Commit

Permalink
updated schema version for the new fields and updated the checker acc…
Browse files Browse the repository at this point in the history
…ordingly
  • Loading branch information
P-T-I committed Oct 10, 2023
1 parent 29818ed commit 8f2853a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 23 deletions.
2 changes: 1 addition & 1 deletion CveXplore/.schema_version
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "1.3",
"version": "1.4",
"rebuild_needed": true
}
2 changes: 1 addition & 1 deletion CveXplore/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.1
0.3.4
37 changes: 16 additions & 21 deletions CveXplore/database/maintenance/DatabaseSchemaChecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,23 @@ def __init__(self):
self.logger = logging.getLogger("SchemaChecker")

def validate_schema(self):
if hasattr(self.dbh.connection, "store_schema"):
try:
if (
not self.schema_version["version"]
== list(self.dbh.connection.store_schema.find({}))[0]["version"]
):
if not self.schema_version["rebuild_needed"]:
raise DatabaseSchemaError(
"Database is not on the latest schema version; please update the database!"
)
else:
raise DatabaseSchemaError(
"Database schema is not up to date; please re-populate the database!"
)
try:
if (
not self.schema_version["version"]
== list(self.dbh.find({}))[0]["version"]
):
if not self.schema_version["rebuild_needed"]:
raise DatabaseSchemaError(
"Database is not on the latest schema version; please update the database!"
)
else:
return True
except IndexError:
# something went wrong fetching the result from the database; assume re-populate is needed
raise DatabaseSchemaError(
"Database schema is not up to date; please re-populate the database!"
)
else:
raise DatabaseSchemaError(
"Database schema is not up to date; please re-populate the database!"
)
else:
return True
except IndexError:
# something went wrong fetching the result from the database; assume re-populate is needed
raise DatabaseSchemaError(
"Database schema is not up to date; please re-populate the database!"
)
Expand Down

0 comments on commit 8f2853a

Please sign in to comment.