diff --git a/src/utils/PlatformServiceMixin.ts b/src/utils/PlatformServiceMixin.ts index 7cee0ea2..641912f7 100644 --- a/src/utils/PlatformServiceMixin.ts +++ b/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(); }