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
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user