refactor: implement team feedback for active identity migration structure

- Update migration 003 to match master deployment (hasBackedUpSeed)
- Rename migration 004 for active_identity table creation
- Update migration service validation for new structure
- Fix TypeScript compatibility issue in migration.ts
- Streamline active identity upgrade plan documentation
- Ensure all migrations are additional per team guidance

Migration structure now follows "additional migrations only" principle:
- 003: hasBackedUpSeed (assumes master deployment)
- 004: active_identity table with data migration
- iOS/Android compatibility confirmed with SQLCipher 4.9.0

Files: migration.ts, migrationService.ts, active-identity-upgrade-plan.md
This commit is contained in:
Matthew Raymer
2025-09-11 13:08:37 +00:00
parent 7917e707e9
commit 31f66909fa
3 changed files with 311 additions and 421 deletions

View File

@@ -280,7 +280,23 @@ async function validateMigrationApplication<T>(
error,
);
}
} else if (migration.name === "003_active_identity_and_seed_backup") {
} else if (migration.name === "003_add_hasBackedUpSeed_to_settings") {
// Validate hasBackedUpSeed column exists in settings table
try {
await sqlQuery(`SELECT hasBackedUpSeed FROM settings LIMIT 1`);
validation.isValid = true;
validation.hasExpectedColumns = true;
} catch (error) {
validation.isValid = false;
validation.errors.push(
`Column hasBackedUpSeed missing from settings table`,
);
logger.error(
`❌ [Migration-Validation] Column hasBackedUpSeed missing:`,
error,
);
}
} else if (migration.name === "004_active_identity_and_seed_backup") {
// Validate active_identity table exists and has correct structure
try {
// Check that active_identity table exists
@@ -315,29 +331,13 @@ async function validateMigrationApplication<T>(
} catch (error) {
validation.isValid = false;
validation.errors.push(
`Validation error for active_did_separation: ${error}`,
`Validation error for active_identity_and_seed_backup: ${error}`,
);
logger.error(
`❌ [Migration-Validation] Validation failed for ${migration.name}:`,
error,
);
}
} else if (migration.name === "003b_add_hasBackedUpSeed_to_settings") {
// Validate hasBackedUpSeed column exists in settings table
try {
await sqlQuery(`SELECT hasBackedUpSeed FROM settings LIMIT 1`);
validation.isValid = true;
validation.hasExpectedColumns = true;
} catch (error) {
validation.isValid = false;
validation.errors.push(
`Column hasBackedUpSeed missing from settings table`,
);
logger.error(
`❌ [Migration-Validation] Column hasBackedUpSeed missing:`,
error,
);
}
}
// Add validation for future migrations here
@@ -401,7 +401,15 @@ async function isSchemaAlreadyPresent<T>(
// Reduced logging - only log on error
return false;
}
} else if (migration.name === "003_active_identity_and_seed_backup") {
} else if (migration.name === "003_add_hasBackedUpSeed_to_settings") {
// Check if hasBackedUpSeed column exists in settings table
try {
await sqlQuery(`SELECT hasBackedUpSeed FROM settings LIMIT 1`);
return true;
} catch (error) {
return false;
}
} else if (migration.name === "004_active_identity_and_seed_backup") {
// Check if active_identity table exists and has correct structure
try {
// Check that active_identity table exists
@@ -608,7 +616,7 @@ export async function runMigrations<T>(
);
// Debug: Check if active_identity table exists and has data
if (migration.name === "003_active_identity_and_seed_backup") {
if (migration.name === "004_active_identity_and_seed_backup") {
try {
const tableCheck = await sqlQuery(
"SELECT name FROM sqlite_master WHERE type='table' AND name='active_identity'",