Skip to content

Commit

Permalink
database.files_db:FileDB - check database version if it is initialise…
Browse files Browse the repository at this point in the history
…d, otherwise initialise it
  • Loading branch information
MatteoCampinoti94 committed Aug 5, 2024
1 parent 17c321f commit e91e24d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions acacore/database/files_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from .base import FileDBBase
from .base import SelectColumn
from .column import model_to_columns
from .update import is_latest


class HistoryEntryPath(HistoryEntry):
Expand Down Expand Up @@ -200,6 +201,11 @@ def __init__(
],
)

if self.is_initialised():
is_latest(self, raise_on_difference=True)
else:
self.init()

def is_initialised(self, *, check_views: bool = True, check_indices: bool = True) -> bool:
tables: set[str] = {n.lower() for [n] in self.execute("select type, name from sqlite_master group by type")}
if not {self.files.name.lower(), self.history.name.lower(), self.metadata.name.lower()}.issubset(set(tables)):
Expand Down

0 comments on commit e91e24d

Please sign in to comment.