Bulk delete transactions by filter from the OptimalOS transactions table
Performs bulk deletion of transactions from OptimalOS's transactions table based on filter criteria. Used to clean up bad imports, remove duplicate batches, or clear test data. Requires explicit confirmation due to the destructive nature of the operation. Always creates an audit log entry before deleting.
upload_batches.id. This is the safest and most common deletion method.--batch-id.YYYY-MM-DD:YYYY-MM-DD (inclusive).chase_checking, chase_credit, discover, generic).lib/transactions/ingest.ts::deleteBatch(options) to orchestrate the deletionSELECT COUNT(*) FROM transactions WHERE <filters> to show impact--dry-run, display count and sample rows, then exit--confirm is set, display count and ask for explicit confirmationcli_task_logs with deletion details (filter, count, timestamp)DELETE FROM transactions WHERE <filters> in batches of 100--batch-id used, update upload_batches.status to deletedlib/board/index.ts::logActivity()Filter: batch_id = 42
Affected rows: 231 transactions
Date range: 2025-11-01 to 2025-11-30
Bank: chase_credit
Deleted: 231 transactions
Batch 42 marked as deleted.
Audit log entry: cli_task_logs.id = 789
Dry-run mode:
[DRY RUN] Would delete 231 transactions matching:
batch_id = 42, bank = chase_credit
Sample: 2025-11-01 "AMAZON.COM" -$47.99, 2025-11-02 "WHOLE FOODS" -$82.31, ...
# Delete by batch ID (safest)
optimal delete-batch --batch-id 42
# Delete by user and date range
optimal delete-batch --user-id <uuid> --date-range 2025-11-01:2025-11-30
# Dry run to preview
optimal delete-batch --batch-id 42 --dry-run
# Skip confirmation prompt
optimal delete-batch --batch-id 42 --confirm
Requires: OPTIMAL_SUPABASE_URL, OPTIMAL_SUPABASE_SERVICE_KEY
transactions — DELETE matching rowsupload_batches — update status to deleted (if batch-id used)cli_task_logs — audit trail entry--confirm is explicitly passed.--batch-id is the safest method because it deletes exactly what was imported in one operation, with clean provenance tracking.categories.Implementation status: Not yet implemented. Spec only. Lib function to be added to lib/transactions/ingest.ts alongside existing ingestion logic.