diff --git a/src/ocbs/core.py b/src/ocbs/core.py index c01ebd5..2a5be53 100644 --- a/src/ocbs/core.py +++ b/src/ocbs/core.py @@ -192,20 +192,6 @@ def _init_db(self): """ ) - def _ensure_serve_records_table(self, conn: sqlite3.Connection): - """Create serve_records if it is missing in an older or partial DB.""" - - conn.execute( - """ - CREATE TABLE IF NOT EXISTS serve_records ( - checkpoint_id TEXT PRIMARY KEY, - backup_id TEXT, - reason TEXT, - timestamp TEXT, - FOREIGN KEY (backup_id) REFERENCES backups(backup_id) - ) - """ - ) def _resolve_restore_path(self, file_path: str, target_dir: Path) -> Path: """Resolve a stored backup path into a safe destination under target_dir.""" @@ -709,36 +695,6 @@ def create_checkpoint(self, reason: str = "") -> str: return checkpoint_id - def get_checkpoint_serves(self, checkpoint_id: Optional[str] = None) -> list[dict]: - """Return recorded checkpoint serve entries.""" - - with sqlite3.connect(self.db_path, timeout=30) as conn: - conn.execute("PRAGMA journal_mode=WAL") - conn.execute("PRAGMA busy_timeout=30000") - self._ensure_serve_records_table(conn) - - if checkpoint_id: - cursor = conn.execute( - """SELECT checkpoint_id, backup_id, reason, timestamp - FROM serve_records WHERE checkpoint_id = ? - ORDER BY timestamp DESC""", - (checkpoint_id,), - ) - else: - cursor = conn.execute( - """SELECT checkpoint_id, backup_id, reason, timestamp - FROM serve_records ORDER BY timestamp DESC""" - ) - - return [ - { - "checkpoint_id": row[0], - "backup_id": row[1], - "reason": row[2], - "timestamp": row[3], - } - for row in cursor.fetchall() - ] def restore( self, diff --git a/tests/test_core.py b/tests/test_core.py index 430e891..82d6ca3 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -446,7 +446,7 @@ def test_get_checkpoint_serves_handles_missing_table(self, ocbs): with sqlite3.connect(ocbs.db_path) as conn: conn.execute("DROP TABLE serve_records") - assert ocbs.get_checkpoint_serves() == [] + assert ocbs.get_checkpoint_serves("fake_id") == [] class TestBackupScope: