From 448d8a68d29d1baf12711cef2780e1e23aa03959 Mon Sep 17 00:00:00 2001 From: Jose Olarte III Date: Fri, 5 Sep 2025 17:51:32 +0800 Subject: [PATCH] fix: improve code formatting in migrationService.ts - Fix line breaks and indentation for long SQL queries - Improve readability of error message formatting - Remove trailing whitespace and standardize spacing - Apply consistent formatting to active_identity table validation logic --- src/services/migrationService.ts | 36 +++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/src/services/migrationService.ts b/src/services/migrationService.ts index 9869512d..96862901 100644 --- a/src/services/migrationService.ts +++ b/src/services/migrationService.ts @@ -287,10 +287,12 @@ async function validateMigrationApplication( const activeIdentityResult = await sqlQuery( `SELECT name FROM sqlite_master WHERE type='table' AND name='active_identity'`, ); - const hasActiveIdentityTable = - (activeIdentityResult as unknown as { values: unknown[][] })?.values?.length > 0 || - (Array.isArray(activeIdentityResult) && activeIdentityResult.length > 0); - + const hasActiveIdentityTable = + (activeIdentityResult as unknown as { values: unknown[][] })?.values + ?.length > 0 || + (Array.isArray(activeIdentityResult) && + activeIdentityResult.length > 0); + if (!hasActiveIdentityTable) { validation.isValid = false; validation.errors.push(`Table active_identity missing`); @@ -298,17 +300,23 @@ async function validateMigrationApplication( // Check that active_identity has the expected structure try { - await sqlQuery(`SELECT id, activeDid, lastUpdated FROM active_identity LIMIT 1`); + await sqlQuery( + `SELECT id, activeDid, lastUpdated FROM active_identity LIMIT 1`, + ); validation.hasExpectedColumns = true; } catch (error) { validation.isValid = false; - validation.errors.push(`active_identity table missing expected columns`); + validation.errors.push( + `active_identity table missing expected columns`, + ); } validation.tableExists = hasActiveIdentityTable; } catch (error) { validation.isValid = false; - validation.errors.push(`Validation error for active_did_separation: ${error}`); + validation.errors.push( + `Validation error for active_did_separation: ${error}`, + ); logger.error( `❌ [Migration-Validation] Validation failed for ${migration.name}:`, error, @@ -384,17 +392,21 @@ async function isSchemaAlreadyPresent( const activeIdentityResult = await sqlQuery( `SELECT name FROM sqlite_master WHERE type='table' AND name='active_identity'`, ); - const hasActiveIdentityTable = - (activeIdentityResult as unknown as { values: unknown[][] })?.values?.length > 0 || - (Array.isArray(activeIdentityResult) && activeIdentityResult.length > 0); - + const hasActiveIdentityTable = + (activeIdentityResult as unknown as { values: unknown[][] })?.values + ?.length > 0 || + (Array.isArray(activeIdentityResult) && + activeIdentityResult.length > 0); + if (!hasActiveIdentityTable) { return false; } // Check that active_identity has the expected structure try { - await sqlQuery(`SELECT id, activeDid, lastUpdated FROM active_identity LIMIT 1`); + await sqlQuery( + `SELECT id, activeDid, lastUpdated FROM active_identity LIMIT 1`, + ); return true; } catch (error) { return false;