Skip to content

Commit

Permalink
database.files_db:FilesDB - add init parameters to check version and …
Browse files Browse the repository at this point in the history
…initialization
  • Loading branch information
MatteoCampinoti94 committed Nov 12, 2024
1 parent 750fe9f commit 51a7052
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion acacore/database/files_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def __init__(
detect_types: int = 0,
isolation_level: str | None = "DEFERRED",
check_same_thread: bool = True,
check_initialisation: bool = False,
check_version: bool = True,
cached_statements: int = 100,
) -> None:
super().__init__(
Expand Down Expand Up @@ -157,7 +159,10 @@ def __init__(

self.metadata: KeysTable[Metadata] = KeysTable(self.connection, Metadata, "metadata")

if self.is_initialised():
if (check_initialisation or check_version) and not self.is_initialised():
raise DatabaseError("Database is not initialized")

if check_version and self.is_initialised():
is_latest(self.connection, raise_on_difference=True)

def upgrade(self):
Expand Down

0 comments on commit 51a7052

Please sign in to comment.