"""Helpers for removing local SQLite databases safely."""

from __future__ import annotations

from pathlib import Path


def sqlite_sidecar_paths(db_path: Path) -> list[Path]:
    """Return the SQLite database file and its WAL/SHM sidecars."""
    db_path = Path(db_path)
    return [
        db_path,
        db_path.with_name(db_path.name + "-wal"),
        db_path.with_name(db_path.name + "-shm"),
    ]


def remove_sqlite_database(db_path: Path) -> list[str]:
    """Delete the SQLite database file plus WAL/SHM sidecars if present."""
    removed: list[str] = []
    for path in sqlite_sidecar_paths(db_path):
        try:
            path.unlink()
            removed.append(str(path))
        except FileNotFoundError:
            continue
    return removed
