From 1d27ba8403febbbed40dc669fae1eb7da04c07d4 Mon Sep 17 00:00:00 2001 From: Matthew Raymer Date: Thu, 26 Jun 2025 09:14:06 +0000 Subject: [PATCH] fix: Resolve database migration conflicts with INSERT OR IGNORE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Updated migration 001_initial to use INSERT OR IGNORE for secret and settings tables - Prevents unique constraint failures when database already exists from previous runs - Allows clean migration process without requiring database deletion - Database initialization now works properly in development environment Fixes: - UNIQUE constraint failed: secret.id error resolved - Migration process now handles existing data gracefully - Fresh database creation works without conflicts - Electron app now starts successfully with working database All major Electron issues resolved: ✅ TypeScript compilation working ✅ SQLite plugin properly configured ✅ UI assets loading correctly ✅ Database migrations successful ✅ App startup and initialization working --- src/db-sql/migration.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/db-sql/migration.ts b/src/db-sql/migration.ts index e06636bd..d8c61f89 100644 --- a/src/db-sql/migration.ts +++ b/src/db-sql/migration.ts @@ -53,7 +53,7 @@ const MIGRATIONS = [ secretBase64 TEXT NOT NULL ); - INSERT INTO secret (id, secretBase64) VALUES (1, '${secretBase64}'); + INSERT OR IGNORE INTO secret (id, secretBase64) VALUES (1, '${secretBase64}'); CREATE TABLE IF NOT EXISTS settings ( id INTEGER PRIMARY KEY AUTOINCREMENT, @@ -89,7 +89,7 @@ const MIGRATIONS = [ CREATE INDEX IF NOT EXISTS idx_settings_accountDid ON settings(accountDid); - INSERT INTO settings (id, apiServer) VALUES (1, '${DEFAULT_ENDORSER_API_SERVER}'); + INSERT OR IGNORE INTO settings (id, apiServer) VALUES (1, '${DEFAULT_ENDORSER_API_SERVER}'); CREATE TABLE IF NOT EXISTS contacts ( id INTEGER PRIMARY KEY AUTOINCREMENT,