Repository navigation
Closed
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
Description
Describe the solution you'd like
I would like a new administrative CLI script, likely triggered via npm run clean-db, that provides a safe and structured way to wipe or prune the events table. Other tables are out of scope.
Functional Requirements:
- Safety First: The script must require an explicit confirmation (e.g.,
Type 'DELETE' to confirm) or a--forceflag to prevent accidental data loss in production. - Flexible Purging Options:
--all: Perform a full wipe of the events data.--older-than=[days]: Delete events based on thecreated_attimestamp.--kinds=[1,7,4]: Target specific Nostr event kinds for removal.
- PostgreSQL Optimizations:
- For the
--allflag, the script should useTRUNCATE TABLE events RESTART IDENTITY CASCADE;for near-instant execution and immediate disk space reclamation. - For selective deletes, the script should run
VACUUM ANALYZE events;afterward to ensure the Postgres query planner is updated.
- For the
- Dry Run: A
--dry-runflag to output the count of rows that would be affected without executing the deletion.
Describe alternatives you've considered
- Manual SQL execution: Hard to script and maintain across different deployment environments.
- Dropping the Database: Overkill, as it requires re-running migrations and re-configuring permissions/extensions (like
pgcrypto).
Additional context
Technical Implementation Details:
- Batching: If deleting millions of rows via
--older-than, the script should ideally delete in batches to avoid bloating the WAL (Write-Ahead Log) or locking the table for an extended period. Optional. - Referential Integrity: Ensure that related data in auxiliary tables (like tags or deletions) is handled correctly, leveraging PostgreSQL's
CASCADEor explicit sub-queries. - Environment Check: The script should check the
NODE_ENVand provide an extra warning if it detects aproductionenvironment.
Expected Outcomes:
- A new
clean-dbutility script. - The ability to quickly reset a relay's state during data-heavy testing.
- Updated
README.mdinstructions for relay maintenance.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
Activity
Priyanshubhartistm commentedon Apr 9, 2026
Hi @cameri,
I want to work on this issue. Could you please assign it to me? 🙏
I'm interested in implementing the wipe events table script as described.
Thanks!
YashIIT0909 commentedon Apr 9, 2026
Hi @cameri, can I work on this issue
chappie-daemon commentedon Apr 9, 2026
Hi @YashIIT0909, thanks for your interest! We're practicing fairness in issue assignment—each contributor gets one open issue at a time so everyone has a chance. You're currently working on #411. Once you've completed that, feel free to come back and we'd love to have you work on this one too! 💪
Priyanshubhartistm commentedon Apr 9, 2026
Hi @phoenix-server @cameri, can I work on this issue? I’m not working on any other issue right now, so can i start
cameri commentedon Apr 9, 2026
Done