Fix database migration errors by improving error handling

- Enhanced migration service to handle duplicate column errors gracefully
- Added detection for 'duplicate column' and 'already exists' errors
- Migration service now marks partially applied migrations as complete
- Prevents Electron app crashes due to cross-platform database conflicts
- Improved robustness for database schema migrations

Fixes database initialization issues when switching between platforms
(web, mobile, electron) that may have different migration states.
This commit is contained in:
Matthew Raymer
2025-06-27 08:29:31 +00:00
parent c13008d476
commit b8b0ebdf4d
3 changed files with 97 additions and 12 deletions

View File

@@ -121,6 +121,11 @@ const MIGRATIONS = [
{
name: "002_add_iViewContent_to_contacts",
sql: `
-- We need to handle the case where iViewContent column might already exist
-- SQLite doesn't support IF NOT EXISTS for ALTER TABLE ADD COLUMN
-- So we'll use a more robust approach with error handling in the migration service
-- First, try to add the column - this will fail silently if it already exists
ALTER TABLE contacts ADD COLUMN iViewContent BOOLEAN DEFAULT TRUE;
`,
},