Skip to content

feat: in-app delete for journal trades + account purge - #4

Merged
ghwmelite-dotcom merged 1 commit into
mainfrom
feat/in-app-delete
Jul 1, 2026
Merged

feat: in-app delete for journal trades + account purge#4
ghwmelite-dotcom merged 1 commit into
mainfrom
feat/in-app-delete

Conversation

@ghwmelite-dotcom

Copy link
Copy Markdown
Owner

Summary

Adds proper in-app delete controls so cleaning up data (e.g. old synced trades after re-syncing an account) never requires raw production SQL again. Every path is ownership-scoped — a user can only ever delete their own rows.

Journal deletes

  • DELETE /journal/trades/:accountId — filter-aware bulk delete (same from/to/symbol/direction/session_tag filters as the GET list); no filters = clear the account's whole journal. Returns the deleted count.
  • DELETE /journal/trades/:accountId/:dealTicket — delete one trade.
  • JournalPage: a Delete button opens a modal with two modes — Before a date (pick e.g. 2026-06-01 to remove everything before June 2026; UTC) and Clear entire journal (type the account name to confirm) — plus a per-row trash button.

Account hard-delete (purge)

  • DELETE /accounts/:id/purge — atomic db.batch() that removes the account and every row referencing it: journal_trades, symbol_mappings, follower_config, prop_rules, daily_stats, blocked_trades, firm_templates, signals, executions, provider_profiles, marketplace_subscriptions, then the account itself. Distinct from the existing soft deactivate (DELETE /accounts/:id).
  • Delete Account modal gains a gated "permanently erase this account and all its data" path (type the account name to confirm).

Stores gain deleteTrades/deleteTrade (journal) and purgeAccount (accounts).

Safety

  • All endpoints reuse the existing ownership check (verifyAccountOwnership / WHERE user_id = ?) — multi-tenant safe.
  • Destructive UI actions require explicit confirmation; full-journal-clear and account-purge require typing the account name.
  • Purge is a single atomic batch: if any statement fails, nothing is deleted.

Verification

  • Table/column names for the purge were taken directly from the migrations (0001, 0004, 0006, 0008, 0012).
  • tsc/vite build can't run in the dev environment (no node_modules) — CI Typecheck gates the deploy. I have not exercised the delete flows against a live DB.

🤖 Generated with Claude Code

Replaces the need for raw production SQL to clean up data. All paths are
ownership-scoped (a user can only ever touch their own rows).

Journal:
- DELETE /journal/trades/:accountId — filter-aware bulk delete (from/to
  date, symbol, direction, session); no filters = clear the account's
  journal. Returns the deleted count.
- DELETE /journal/trades/:accountId/:dealTicket — single trade.
- JournalPage: a Delete action opens a modal with "Before a date"
  (e.g. everything before 2026-06-01) and "Clear entire journal" (typed
  confirm) modes, plus a per-row trash button.

Account hard-delete:
- DELETE /accounts/:id/purge — atomic batch that removes the account and
  every row referencing it (journal_trades, symbol_mappings,
  follower_config, prop_rules, daily_stats, blocked_trades, firm_templates,
  signals, executions, provider_profiles, marketplace_subscriptions), then
  the account. Distinct from the existing soft deactivate.
- Delete Account modal gains a gated "permanently erase" path (type the
  account name to confirm).

Stores gain deleteTrades/deleteTrade and purgeAccount.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ghwmelite-dotcom
ghwmelite-dotcom merged commit 790a7de into main Jul 1, 2026
2 checks passed
@ghwmelite-dotcom
ghwmelite-dotcom deleted the feat/in-app-delete branch July 1, 2026 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant