mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-08 17:06:15 -08:00
fix(database): silence expected duplicate-column migration logs
This commit is contained in:
1 parent
c325b94347
commit
9787f79176
1 file changed
+25
-3
@@ -242,6 +242,15 @@ function createTables(sqliteDb: Database.Database): void {
|
||||
}
|
||||
}
|
||||
|
||||
function isDuplicateColumnError(error: unknown): boolean {
|
||||
const message =
|
||||
typeof error === 'object' && error !== null && 'message' in error
|
||||
? String((error as { message?: unknown }).message ?? '')
|
||||
: '';
|
||||
|
||||
return message.toLowerCase().includes('duplicate column name');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run migrations that may fail if already applied
|
||||
*/
|
||||
@@ -250,9 +259,22 @@ function runMigrations(sqliteDb: Database.Database): void {
|
||||
try {
|
||||
sqliteDb.exec(stmt);
|
||||
} catch (error) {
|
||||
// Log and ignore errors for migrations that may have already been applied
|
||||
// (e.g., "duplicate column name" for ALTER TABLE ADD COLUMN)
|
||||
console.debug('Migration already applied or failed:', error);
|
||||
// Ignore idempotent ALTER TABLE errors on existing columns.
|
||||
if (isDuplicateColumnError(error)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const compactStmt = stmt.replace(/\s+/g, ' ').trim();
|
||||
const message =
|
||||
typeof error === 'object' &&
|
||||
error !== null &&
|
||||
'message' in error
|
||||
? String((error as { message?: unknown }).message ?? error)
|
||||
: String(error);
|
||||
|
||||
console.warn(
|
||||
`Migration failed (continuing): ${compactStmt} :: ${message}`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user