Problem
The SQLite messages table grows forever because messages/MessageDatabase.js has helpers for inserting and reading messages but no maintenance operation for removing old history.
Long-running deployments can accumulate unnecessary data and make backups or local inspection harder.
Expected behavior
A maintainer should be able to delete messages older than a chosen timestamp using a parameterized SQL operation without affecting newer messages or other tables.
Suggested direction
Add a small exported helper such as deleteMessagesBefore(timestamp) that executes DELETE FROM messages WHERE timestamp < ?, returns the number of deleted rows, and validates that the timestamp is a finite number.
Acceptance criteria
- The delete operation is parameterized and cannot interpolate user input into SQL.
- Messages newer than the cutoff remain untouched.
- The helper returns a useful deletion count.
- A test covers an empty table, a mixed old/new table, and an invalid cutoff.
Problem
The SQLite
messagestable grows forever becausemessages/MessageDatabase.jshas helpers for inserting and reading messages but no maintenance operation for removing old history.Long-running deployments can accumulate unnecessary data and make backups or local inspection harder.
Expected behavior
A maintainer should be able to delete messages older than a chosen timestamp using a parameterized SQL operation without affecting newer messages or other tables.
Suggested direction
Add a small exported helper such as
deleteMessagesBefore(timestamp)that executesDELETE FROM messages WHERE timestamp < ?, returns the number of deleted rows, and validates that the timestamp is a finite number.Acceptance criteria