Browse Source

feat(migration): complete Step 2 of ActiveDid migration - implement dual-write pattern

- Add database persistence to $updateActiveDid() method
- Implement dual-write to both active_identity and settings tables
- Add error handling with graceful fallback to in-memory updates
- Include debug logging for migration monitoring
pull/188/head
Matthew Raymer 2 weeks ago
parent
commit
f63f4856bf
  1. 21
      src/utils/PlatformServiceMixin.ts

21
src/utils/PlatformServiceMixin.ts

@ -212,6 +212,27 @@ export const PlatformServiceMixin = {
logger.debug(
`[PlatformServiceMixin] ActiveDid updated from ${oldDid} to ${newDid}`,
);
// Dual-write to both tables for backward compatibility
try {
await this.$dbExec(
"UPDATE active_identity SET activeDid = ?, lastUpdated = datetime('now') WHERE id = 1",
[newDid || ""],
);
await this.$dbExec("UPDATE settings SET activeDid = ? WHERE id = 1", [
newDid || "",
]);
logger.debug(
`[PlatformServiceMixin] ActiveDid dual-write completed for ${newDid}`,
);
} catch (error) {
logger.error(
`[PlatformServiceMixin] Error in dual-write for activeDid ${newDid}:`,
error,
);
// Continue with in-memory update even if database write fails
}
// // Clear caches that might be affected by the change
// this.$clearAllCaches();
}

Loading…
Cancel
Save