Add default value for a(ction) field in change records to keep support for very old versions.

This commit is contained in:
2026-02-19 20:16:16 +00:00
parent f5ccc204be
commit be177cbafc
+3 -3
View File
@@ -34,7 +34,7 @@ _logger = logging.getLogger(__name__)
class ReplayResult(msgspec.Struct, frozen=False): class ReplayResult(msgspec.Struct, frozen=False):
"""Return value of _replay_from_data""" """Return value of _replay_from_data"""
state: dict state: dict = {}
v: int = 0 v: int = 0
ts: datetime | None = None ts: datetime | None = None
snapts: datetime | None = None snapts: datetime | None = None
@@ -50,7 +50,7 @@ class DatabaseError(Exception):
def _replay_from_data(data: bytes, db_path: str) -> ReplayResult: def _replay_from_data(data: bytes, db_path: str) -> ReplayResult:
"""Replay database state from file data, using the last snapshot if available.""" """Replay database state from file data, using the last snapshot if available."""
resolved_path = str(Path(db_path).resolve()) resolved_path = str(Path(db_path).resolve())
result = ReplayResult(state={}) result = ReplayResult()
# Find and apply the last snapshot # Find and apply the last snapshot
snap, start_offset = SnapshotState.load(data) snap, start_offset = SnapshotState.load(data)
@@ -115,7 +115,7 @@ def load_readonly(db_path: str, *, rp_id: str = "localhost") -> DB:
class ChangeRecord(msgspec.Struct, omit_defaults=True, kw_only=True): class ChangeRecord(msgspec.Struct, omit_defaults=True, kw_only=True):
ts: datetime = msgspec.field(default_factory=lambda: datetime.now(UTC)) ts: datetime = msgspec.field(default_factory=lambda: datetime.now(UTC))
a: str # action - describes the operation (e.g., "migrate", "login", "create_user") a: str = "" # action (e.g., "migrate", "login", "create_user")
v: int = 0 # schema version after this change v: int = 0 # schema version after this change
u: str | None = None # user UUID who performed the action (None for system) u: str | None = None # user UUID who performed the action (None for system)
diff: dict diff: dict