Coverage for seedboxsync/core/dao/seedboxsync.py: 100%
11 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-26 17:46 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-26 17:46 +0000
1#
2# Copyright (C) 2015-2026 Guillaume Kulakowski <guillaume@kulakowski.fr>
3#
4# For the full copyright and license information, please view the LICENSE
5# file that was distributed with this source code.
6#
7"""Peewee DAO model for SeedboxSync."""
9from peewee import CharField, TextField
10from seedboxsync.core.dao import SeedboxSyncModel
13class SeedboxSync(SeedboxSyncModel):
14 """
15 Data Access Object (DAO) for application metadata and internal configuration.
17 This table stores key-value pairs used for SeedboxSync's internal state
18 management and configuration, such as taskstatus, versioning, or runtime
19 parameters.
21 Attributes:
22 key (str): Unique identifier for the configuration entry.
23 value (str): Stored value associated with the key.
24 """
26 key = CharField(primary_key=True)
27 value = TextField()
29 @staticmethod
30 def get_db_version() -> str:
31 """
32 Return database model version.
34 Returns:
35 str: The database model version.
36 """
37 return str(SeedboxSync.select(SeedboxSync.value).where(SeedboxSync.key == "db_version").first().value) # Use old style to prevent Peewee 2 databases.
39 @staticmethod
40 def set_db_version(db_version: str) -> None:
41 """
42 Upsert database model version.
44 Args:
45 db_version (str): The database model version.
46 """
47 SeedboxSync.replace(key="db_version", value=db_version).execute() # type: ignore[no-untyped-call]