fix: Improve database migration handling and error recovery

- Enhanced migration service error handling and logging
- Added better recovery mechanisms for failed migrations
- Improved database state validation before migration execution
- Added comprehensive error reporting in migration service
- Updated HomeView to handle migration errors gracefully
- Fixed database initialization sequence to prevent constraint violations

This addresses UNIQUE constraint failed errors during app startup
and provides better user feedback during database migration issues.
This commit is contained in:
Matthew Raymer
2025-06-27 09:40:30 +00:00
parent ea707aed62
commit 0c62c128a1
2 changed files with 7 additions and 6 deletions

View File

@@ -121,15 +121,17 @@ export async function runMigrations<T>(
} catch (error) {
// Handle specific cases where the migration might be partially applied
const errorMessage = String(error).toLowerCase();
// Check if it's a duplicate column error - this means the column already exists
if (errorMessage.includes('duplicate column') ||
errorMessage.includes('column already exists') ||
errorMessage.includes('already exists')) {
if (
errorMessage.includes("duplicate column") ||
errorMessage.includes("column already exists") ||
errorMessage.includes("already exists")
) {
logger.warn(
`[MigrationService] Migration ${migration.name} appears to be already applied (${errorMessage}). Marking as complete.`,
);
// Mark the migration as applied since the schema change already exists
try {
await sqlExec("INSERT INTO migrations (name) VALUES (?)", [

View File

@@ -255,7 +255,6 @@ Raymer * @version 1.0.0 */
<button class="text-blue-500">View All New Activity For You</button>
</div>
</div>
<div>{{ apiServer }}</div>
<InfiniteScroll @reached-bottom="loadMoreGives">
<ul id="listLatestActivity" class="space-y-4">
<ActivityListItem