The schema has zero foreign key constraints. Instances are first-class citizens that can exist with or without a parent task. When updating an orphaned instance, the module falls back to the raw Convex task_id:
const parentTask = await db.getFirstAsync( "SELECT id FROM local_tasks WHERE convex_id = ?", [instance.task_id]);const localTaskId = parentTask?.id ?? instance.task_id; // Fallback for orphans
Updates use a “delete then insert” strategy within a transaction. This guarantees that even if the column set changes between versions, the row is always fresh and complete.