storage: add upload_files table and UploadRepo
Add the upload_files SQLite table and UploadRepo CRUD methods (Create/Get/List/Delete). The table stores file_id, name, size, sha256, and uploaded_at as a queryable index. The .meta.json sidecar remains the source of truth for uploads; the DB is only an index for admin visibility. On startup the next commit will backfill any pre-existing sidecars into this table. Tests cover Create/Get/List/Delete round-trip, name search filtering, descending time ordering, and limit defaults/cap. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -38,6 +38,15 @@ CREATE TABLE IF NOT EXISTS audit_log (
|
||||
details TEXT
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_audit_ts ON audit_log(timestamp DESC);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS upload_files (
|
||||
file_id TEXT PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
size INTEGER NOT NULL,
|
||||
sha256 TEXT NOT NULL,
|
||||
uploaded_at INTEGER NOT NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_uploads_ts ON upload_files(uploaded_at DESC);
|
||||
`
|
||||
|
||||
// DB is the storage handle.
|
||||
|
||||
Reference in New Issue
Block a user