forked from jsnbuchanan/crowd-funder-for-time-pwa
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
This commit is contained in:
@@ -287,10 +287,12 @@ async function validateMigrationApplication<T>(
|
|||||||
const activeIdentityResult = await sqlQuery(
|
const activeIdentityResult = await sqlQuery(
|
||||||
`SELECT name FROM sqlite_master WHERE type='table' AND name='active_identity'`,
|
`SELECT name FROM sqlite_master WHERE type='table' AND name='active_identity'`,
|
||||||
);
|
);
|
||||||
const hasActiveIdentityTable =
|
const hasActiveIdentityTable =
|
||||||
(activeIdentityResult as unknown as { values: unknown[][] })?.values?.length > 0 ||
|
(activeIdentityResult as unknown as { values: unknown[][] })?.values
|
||||||
(Array.isArray(activeIdentityResult) && activeIdentityResult.length > 0);
|
?.length > 0 ||
|
||||||
|
(Array.isArray(activeIdentityResult) &&
|
||||||
|
activeIdentityResult.length > 0);
|
||||||
|
|
||||||
if (!hasActiveIdentityTable) {
|
if (!hasActiveIdentityTable) {
|
||||||
validation.isValid = false;
|
validation.isValid = false;
|
||||||
validation.errors.push(`Table active_identity missing`);
|
validation.errors.push(`Table active_identity missing`);
|
||||||
@@ -298,17 +300,23 @@ async function validateMigrationApplication<T>(
|
|||||||
|
|
||||||
// Check that active_identity has the expected structure
|
// Check that active_identity has the expected structure
|
||||||
try {
|
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;
|
validation.hasExpectedColumns = true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
validation.isValid = false;
|
validation.isValid = false;
|
||||||
validation.errors.push(`active_identity table missing expected columns`);
|
validation.errors.push(
|
||||||
|
`active_identity table missing expected columns`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
validation.tableExists = hasActiveIdentityTable;
|
validation.tableExists = hasActiveIdentityTable;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
validation.isValid = false;
|
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(
|
logger.error(
|
||||||
`❌ [Migration-Validation] Validation failed for ${migration.name}:`,
|
`❌ [Migration-Validation] Validation failed for ${migration.name}:`,
|
||||||
error,
|
error,
|
||||||
@@ -384,17 +392,21 @@ async function isSchemaAlreadyPresent<T>(
|
|||||||
const activeIdentityResult = await sqlQuery(
|
const activeIdentityResult = await sqlQuery(
|
||||||
`SELECT name FROM sqlite_master WHERE type='table' AND name='active_identity'`,
|
`SELECT name FROM sqlite_master WHERE type='table' AND name='active_identity'`,
|
||||||
);
|
);
|
||||||
const hasActiveIdentityTable =
|
const hasActiveIdentityTable =
|
||||||
(activeIdentityResult as unknown as { values: unknown[][] })?.values?.length > 0 ||
|
(activeIdentityResult as unknown as { values: unknown[][] })?.values
|
||||||
(Array.isArray(activeIdentityResult) && activeIdentityResult.length > 0);
|
?.length > 0 ||
|
||||||
|
(Array.isArray(activeIdentityResult) &&
|
||||||
|
activeIdentityResult.length > 0);
|
||||||
|
|
||||||
if (!hasActiveIdentityTable) {
|
if (!hasActiveIdentityTable) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that active_identity has the expected structure
|
// Check that active_identity has the expected structure
|
||||||
try {
|
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;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user