feat(activeDid): implement migration to separate active_identity table

- Add migration 003 with data migration logic to prevent data loss
- Create dedicated ActiveIdentity interface in separate file for better architecture
- Implement $getActiveIdentity method in PlatformServiceMixin
- Enhance $updateActiveDid with dual-write pattern for backward compatibility
- Maintain separation of concerns between settings and active identity types
- Follow project architectural pattern with dedicated type definition files

The migration creates active_identity table alongside existing settings,
automatically copying existing activeDid data to prevent user data loss.
Dual-write pattern ensures backward compatibility during transition.

Migration includes:
- Schema creation with proper constraints and indexes
- Automatic data transfer from settings.activeDid to active_identity.activeDid
- Validation to ensure data exists before migration
- Atomic operation: schema and data migration happen together
This commit is contained in:
Matthew Raymer
2025-08-29 11:48:22 +00:00
parent 95b0cbca78
commit 4a22a35b3e
4 changed files with 81 additions and 2 deletions

View File

@@ -117,10 +117,10 @@ runs on existing databases.
### **2. Type Definitions**
Create ActiveIdentity interface in `src/db/tables/settings.ts`:
Create ActiveIdentity interface in `src/db/tables/activeIdentity.ts`:
```typescript
// Add to src/db/tables/settings.ts
// Create new file: src/db/tables/activeIdentity.ts
export interface ActiveIdentity {
id: number;
activeDid: string;
@@ -128,6 +128,9 @@ export interface ActiveIdentity {
}
```
**Note**: This maintains separation of concerns by keeping active identity types
separate from settings types, following the project's architectural pattern.
### **3. PlatformServiceMixin Methods**
Implement required methods in `src/utils/PlatformServiceMixin.ts`: