feat: add phone_calls WatermelonDB table#348
feat: add phone_calls WatermelonDB table#348Charlie McCowan (CharlieMc0) wants to merge 2 commits into
Conversation
Add new phone_calls table (schema v19 → v20) to persist Bland AI phone call data locally. Includes model, CRUD operations, types, and barrel exports following the existing project/media table patterns. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Dependency graphChanged files are highlighted in green. flowchart LR
subgraph 0["src"]
subgraph 1["expo"]
2["index.ts"]
end
subgraph 3["lib"]
subgraph 4["db"]
5["manager.ts"]
6["schema.ts"]
subgraph 7["phone_call"]
8["models.ts"]
9["index.ts"]
A["operations.ts"]
B["types.ts"]
end
end
end
subgraph C["react"]
D["index.ts"]
E["useDatabaseManager.ts"]
end
subgraph F["server"]
G["index.ts"]
H["storage.ts"]
end
end
2-->5
2-->5
2-->6
5-->6
6-->8
9-->8
9-->A
9-->B
A-->8
A-->B
D-->5
D-->5
D-->9
D-->6
D-->E
E-->5
G-->5
G-->5
G-->6
G-->H
H-->5
style 6 fill:lime,color:black
style 8 fill:lime,color:black
style 9 fill:lime,color:black
style A fill:lime,color:black
style B fill:lime,color:black
style D fill:lime,color:black
|
Coverage Report
File CoverageNo changed files found. |
API Changes
|
Integration Check ✅
|
|
Hard-deletes all phone call records for a conversation. Prevents unbounded table growth when conversations are cleaned up. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Thanks for the thorough review Pasumarthi Rutwik (@rutwik2001)! Here's the breakdown: 1. 2. 3. Unsafe cast 4. Schema 5. No delete operation — Good catch. Added 6. |
| */ | ||
| export const SDK_SCHEMA_VERSION = 19; | ||
| export const SDK_SCHEMA_VERSION = 20; | ||
|
|
There was a problem hiding this comment.
The branch is ~20 commits behind main, and the schema version has moved to v27. This migration targets v19→20, but v20 on main is already the updated_at index migration for memory_vault. We need a rebase so the phone_calls migration lands as v28 and doesn't collide with existing versions.
|
Schema version collision (blocking) — The branch HEAD is still |
|
src/lib/db/schema.ts — |
|
src/lib/db/phone_call/models.ts — Every other table with a |
|
src/lib/db/phone_call/operations.ts:38-47 — |
|
src/lib/db/phone_call/models.ts:13 — Sibling models ( |
|
src/lib/db/phone_call/models.ts:10 — |
| /** | ||
| * Delete all phone call records for a conversation. | ||
| */ | ||
| export async function deletePhoneCallsByConversationOp( |
There was a problem hiding this comment.
Lets swap the per-record destroyPermanently() loop for query(...).destroyAllPermanently() — one batched delete inside the write block, no need to materialize the full result set first.
| /** | ||
| * Stored representation of a phone call in the database. | ||
| */ | ||
| export interface StoredPhoneCall { |
There was a problem hiding this comment.
The uniqueId field reads a bit ambiguous next to callId. Could we either rename it to id to match StoredMedia / StoredAppFile, or sharpen the comment so its clear this is the Watermelon row id and not the Bland call id?
Summary
phone_callsWatermelonDB table (schema v19 → v20) to persist Bland AI phone call data locallysrc/lib/db/phone_call/module with model, CRUD operations, and types following existing patterns (project/media)call_id,conversation_id,offer_message_idfor efficient lookups@anuma/sdk/react:PhoneCall,StoredPhoneCall,PhoneCallOperationsContext,createPhoneCallOp,getPhoneCallByOfferOp,getPhoneCallsByConversationOp,updatePhoneCallOpIntegration
Import phone call operations from
@anuma/sdk/react:Breaking Changes
None — additive schema migration only.
Note
Medium Risk
Introduces a schema version bump and new migration; while additive, any issues in table creation/indexing or model registration could break local DB initialization or upgrades.
Overview
Adds a new WatermelonDB-backed
phone_callsstorage module to persist Bland AI call lifecycle data (request/response, status, timestamps) and query it by offer message/conversation.Bumps
SDK_SCHEMA_VERSIONfrom 19→20 with a migration that creates the indexedphone_callstable, registers thePhoneCallmodel, and re-exports the new model/types/operations from@anuma/sdk/react.Written by Cursor Bugbot for commit 79a4114. This will update automatically on new commits. Configure here.