fix linting

This commit is contained in:
2025-05-25 20:48:33 -06:00
parent d6f9567777
commit 26fba66bba
14 changed files with 130 additions and 75 deletions

View File

@@ -1,4 +1,4 @@
import { QueryExecResult } from '../interfaces/database';
import { QueryExecResult } from "../interfaces/database";
interface Migration {
name: string;
@@ -23,7 +23,7 @@ export class MigrationService {
}
async runMigrations(
sqlExec: (sql: string, params?: any[]) => Promise<Array<QueryExecResult>>
sqlExec: (sql: string, params?: any[]) => Promise<Array<QueryExecResult>>,
): Promise<void> {
// Create migrations table if it doesn't exist
await sqlExec(`
@@ -35,12 +35,16 @@ export class MigrationService {
`);
// Get list of executed migrations
const result: QueryExecResult[] = await sqlExec('SELECT name FROM migrations;');
const result: QueryExecResult[] = await sqlExec(
"SELECT name FROM migrations;",
);
let executedMigrations: Set<string> = new Set();
// Even with that query, the QueryExecResult may be [] (which doesn't make sense to me).
if (result.length > 0) {
const singleResult = result[0];
executedMigrations = new Set(singleResult.values.map((row: any[]) => row[0]));
executedMigrations = new Set(
singleResult.values.map((row: any[]) => row[0]),
);
}
// Run pending migrations in order
@@ -48,7 +52,9 @@ export class MigrationService {
if (!executedMigrations.has(migration.name)) {
try {
await sqlExec(migration.sql);
await sqlExec('INSERT INTO migrations (name) VALUES (?)', [migration.name]);
await sqlExec("INSERT INTO migrations (name) VALUES (?)", [
migration.name,
]);
console.log(`Migration ${migration.name} executed successfully`);
} catch (error) {
console.error(`Error executing migration ${migration.name}:`, error);
@@ -59,4 +65,4 @@ export class MigrationService {
}
}
export default MigrationService.getInstance();
export default MigrationService.getInstance();