feat(db): implement active identity table separation
#180
Open
anomalist
wants to merge 1 commits from activedid_migration
into master
pull from: activedid_migration
merge into: trent_larson:master
trent_larson:ai-context
trent_larson:android-15-check
trent_larson:android-file-save
trent_larson:app_id_fix
trent_larson:ask-for-contacts-export
trent_larson:build-dev-to-dist
trent_larson:build-improvement
trent_larson:build-ios
trent_larson:build-web-serve-test
trent_larson:build-with-env
trent_larson:capacitor-local-save
trent_larson:claim-view-error-handling
trent_larson:claimview-fullfills-offer
trent_larson:contact-gifting-current-user
trent_larson:contacts-view-fixes
trent_larson:cross-platform-factory
trent_larson:cross-platform-factory-redux
trent_larson:d9085ced6df7dc7bdcd899959cea6489cab7f8b8
trent_larson:db-backup-cross-platform
trent_larson:deep-link
trent_larson:deep-links-android-update
trent_larson:deep_linking
trent_larson:design-tweaks-2023-12
trent_larson:dialog-styles-unified
trent_larson:didview-invalid-did-handling
trent_larson:electron_fix_20250317
trent_larson:experimental_plugin
trent_larson:eye-slash
trent_larson:fix-contact-import-export
trent_larson:fix-deep-link
trent_larson:fix-service-worker
trent_larson:friend-tech-inspired-pwa-dialog
trent_larson:get-get-hash
trent_larson:gifting-periphery-improvements
trent_larson:gifting-ui-2025-05
trent_larson:home-icon-enhancements
trent_larson:home-view-notification-improvements
trent_larson:homeview-cleanup-2025-03
trent_larson:homeview-refresh-2025-02
trent_larson:imagemagick-anrdoid
trent_larson:ios-contact-copy
trent_larson:logger-level
trent_larson:logging-upgrade
trent_larson:main
trent_larson:master
trent_larson:master-patch
trent_larson:master-settings-upgrade
trent_larson:matthew-scratch-2025-06-28
trent_larson:migrate-dexie-to-sqlite
trent_larson:nearby-filter
trent_larson:new-storage
trent_larson:nostr
trent_larson:notification-line-wrapping
trent_larson:notification-request-permission-dialog
trent_larson:notification-section
trent_larson:notify-time
trent_larson:offer-edit
trent_larson:offer-validation-logic
trent_larson:onboard-alert-component
trent_larson:onboarding-dialog-fix
trent_larson:passkey
trent_larson:passkey-cache
trent_larson:performance-optimizations-testing
trent_larson:photo-reverse
trent_larson:plan-loc
trent_larson:platformservicemixin-interface-consolidation
trent_larson:playwright-pwa-install-test
trent_larson:playwright-test-60-fix
trent_larson:playwright-test-updates
trent_larson:profile-pic
trent_larson:profile_include_location
trent_larson:project-gives
trent_larson:projectview-hide-offer-link-unregistered
trent_larson:qrcode-capacitor
trent_larson:registration-gate
trent_larson:remove-image-cache
trent_larson:replace-iconrenderer
trent_larson:script-build-mode
trent_larson:search-map-fix
trent_larson:side_step
trent_larson:simple-signer
trent_larson:split_build_process
trent_larson:sql-absurd-sql
trent_larson:sql-absurd-sql-further
trent_larson:sql-wa-sqlite
trent_larson:star-projects
trent_larson:starred-projects
trent_larson:streamline-attempt
trent_larson:sw-cleanup
trent_larson:tmp
trent_larson:trent-tweaks
trent_larson:tweaks
trent_larson:ui-fixes-2024-03
trent_larson:ui-fixes-2025-03
trent_larson:ui-fixes-2025-06-w2
trent_larson:units-mocking
trent_larson:v-onboarding-2024-04
trent_larson:vite-version
trent_larson:web-serve-fix
trent_larson:web-tests
Reviewers
Request review
No reviewers
Labels
Apply labels
Clear labels
No items
No Label
Milestone
Set milestone
Clear milestone
No items
No Milestone
Assignees
Assign users
Clear assignees
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.
No due date set.
Dependencies
This pull request currently doesn't have any dependencies.
Reference in new issue
There is no content yet.
Delete Branch 'activedid_migration'
Deleting a branch is permanent. It CANNOT be undone. Continue?
No
Yes
Active Identity Implementation Overview
Author: Matthew Raymer
Date: 2025-08-21T13:40Z
Status: 🚧 IN PROGRESS - Implementation Complete, Testing Pending
Objective
Separate the
activeDid
field from the monolithicsettings
table into adedicated
active_identity
table to achieve:Result
This document provides a comprehensive overview of the implemented Active
Identity table separation system, including architecture, migration strategy,
and component integration.
Use/Run
The implementation is ready for testing. Components can immediately use the new
façade methods while maintaining backward compatibility through dual-write
triggers.
Context & Scope
migrations
integration
identity hierarchies
Artifacts & Links
src/db/tables/activeIdentity.ts
,src/utils/PlatformServiceMixin.ts
src/db-sql/migration.ts
(migrations 003 & 004)src/config/featureFlags.ts
Environment & Preconditions
Architecture / Process Overview
The Active Identity separation follows a phased migration pattern with
dual-write triggers to ensure zero downtime and backward compatibility.
Interfaces & Contracts
Database Schema
active_identity
scope
,active_did
,updated_at
settings
id
,accountDid
,apiServer
,activeDid
removed in Phase CService Façade API
$getActiveDid(scope?)
scope
(default: 'default')Promise<string | null>
$setActiveDid(did, scope?)
did
,scope
(default:Promise<void>
$switchActiveIdentity(did)
did
Promise<void>
$getActiveIdentityScopes()
Promise<string[]>
Repro: End-to-End Procedure
1. Database Migration Execution
2. Component Usage
3. Feature Flag Control
What Works (Evidence)
migrationService.ts
active_identity
table schema with proper constraintsand indexes
settings.activeDid
→active_identity.active_did
What Doesn't (Evidence & Hypotheses)
methods
Risks, Limits, Assumptions
Migration Risks
easily reversible
active_identity
table is corrupted
Performance Limits
activeDid
change triggers additionaldatabase operations
consistency
Security Boundaries
ownership
constraints
active_identity
tableNext Steps
References
Competence Hooks
downtime while maintaining data consistency through foreign key constraints
and validation
USE_ACTIVE_IDENTITY_ONLY
, not testing rollback scenarios, ignoringcross-platform compatibility
and ESLint rules
during the transition phase
Collaboration Hooks
integration, DevOps for deployment strategy
performance validated, rollback plan documented
Assumptions & Limits
'default' scope
vue-facing-decorator
compatibility (needsvalidation)
execution)
Mobile (Capacitor SQLite)
Implementation Details
Migration 003: Table Creation
Creates the
active_identity
table with:Migration 004: Column Removal
Implements Phase C by:
Service Façade Implementation
The PlatformServiceMixin extension provides:
transition
Feature Flag System
Controls migration phases through:
USE_ACTIVE_IDENTITY_ONLY
: Disables legacy fallback readsDROP_SETTINGS_ACTIVEDID
: Enables Phase C column removalLOG_ACTIVE_ID_FALLBACK
: Logs when legacy fallback is usedENABLE_ACTIVE_IDENTITY_MIGRATION
: Master switch for migrationsystem
Security Considerations
Data Validation
Access Control
Audit Trail
Performance Characteristics
Read Operations
active_identity
tablesettings
table (Phase A only)Write Operations
Migration Impact
Testing Strategy
Unit Testing
Integration Testing
End-to-End Testing
Deployment Considerations
Rollout Strategy
Rollback Plan
Monitoring
Status: Implementation complete, ready for testing and component migration
Next Review: After initial testing and component updates
Maintainer: Development team