Skip to content

Add a safe SQL helper for pruning old chat history #36

Description

@cubrift

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    codexUse for codex-generated issues only.enhancementPerformance update or requestgood first issueGood for newcomerssqlSQL-related issues

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions