feat: Add database migration tools and fix Electron integration

- Add comprehensive IndexedDB to SQLite migration service (1,397 lines)
- Create migration UI with progress tracking and validation (1,492 lines)
- Fix Electron TypeScript compilation and SQLite plugin issues
- Expand migration system with detailed documentation and error handling
- Add development guide and coding standards

Resolves: #electron-startup #database-migration #typescript-errors
Impact: Enables user-friendly database migration with full data verification
This commit is contained in:
Matthew Raymer
2025-07-01 03:47:32 +00:00
parent dfa2168d9e
commit a4c44ff052
10 changed files with 3295 additions and 157 deletions

View File

@@ -113,7 +113,7 @@ class MigrationRegistry {
* Adds a migration to the list of migrations that will be applied when
* runMigrations() is called. Migrations should be registered in order
* of their intended execution.
*
*
* @param migration - The migration to register
* @throws {Error} If migration name is empty or already exists
*
@@ -139,7 +139,7 @@ class MigrationRegistry {
/**
* Get all registered migrations
*
*
* Returns a copy of all migrations that have been registered with this
* registry. The migrations are returned in the order they were registered.
*
@@ -176,11 +176,11 @@ const migrationRegistry = new MigrationRegistry();
/**
* Register a migration with the migration service
*
*
* This is the primary public API for registering database migrations.
* Each migration should represent a single, focused schema change that
* can be applied atomically.
*
*
* @param migration - The migration to register
* @throws {Error} If migration is invalid
*
@@ -339,7 +339,7 @@ async function isSchemaAlreadyPresent<T>(
/**
* Run all registered migrations against the database
*
*
* This is the main function that executes the migration process. It:
* 1. Creates the migrations tracking table if needed
* 2. Determines which migrations have already been applied
@@ -350,7 +350,7 @@ async function isSchemaAlreadyPresent<T>(
*
* The function is designed to be idempotent - it can be run multiple times
* safely without re-applying migrations that have already been completed.
*
*
* @template T - The type returned by SQL query operations
* @param sqlExec - Function to execute SQL statements (INSERT, UPDATE, CREATE, etc.)
* @param sqlQuery - Function to execute SQL queries (SELECT)
@@ -532,14 +532,14 @@ export async function runMigrations<T>(
} else {
// For other types of errors, still fail the migration
console.error(`❌ [Migration] Failed to apply ${migration.name}:`, error);
logger.error(
`[MigrationService] Failed to apply migration ${migration.name}:`,
error,
);
throw new Error(`Migration ${migration.name} failed: ${error}`);
}
logger.error(
`[MigrationService] Failed to apply migration ${migration.name}:`,
error,
);
throw new Error(`Migration ${migration.name} failed: ${error}`);
}
}
}
// Step 5: Final validation - verify all migrations are properly recorded
console.log("\n🔍 [Migration] Final validation - checking migrations table...");