refactor(backend): move db repos to typescript and update imports

This commit is contained in:
Haileyesus
2026-03-27 20:10:01 +03:00
parent 33cea381c4
commit 90d234d9f3
26 changed files with 960 additions and 60 deletions

View File

@@ -1,5 +1,14 @@
import { Database } from "better-sqlite3";
import { APP_CONFIG_TABLE_SCHEMA_SQL, LAST_SCANNED_AT_SQL, SESSIONS_TABLE_SCHEMA_SQL, WORK_SPACE_PATH_SQL } from "@/shared/database/schema.js";
import {
APP_CONFIG_TABLE_SCHEMA_SQL,
LAST_SCANNED_AT_SQL,
PUSH_SUBSCRIPTIONS_TABLE_SCHEMA_SQL,
SESSION_NAMES_TABLE_SCHEMA_SQL,
SESSIONS_TABLE_SCHEMA_SQL,
USER_NOTIFICATION_PREFERENCES_TABLE_SCHEMA_SQL,
VAPID_KEYS_TABLE_SCHEMA_SQL,
WORK_SPACE_PATH_SQL
} from "@/shared/database/schema.js";
import { logger } from "@/shared/utils/logger.js";
const addColumnToTableIfNotExists = (
@@ -30,6 +39,16 @@ export const runMigrations = (db: Database) => {
// Create app_config table if it doesn't exist (for existing installations)
db.exec(APP_CONFIG_TABLE_SCHEMA_SQL);
// Create notification and push tables if they don't exist (for existing installations)
db.exec(USER_NOTIFICATION_PREFERENCES_TABLE_SCHEMA_SQL);
db.exec(VAPID_KEYS_TABLE_SCHEMA_SQL);
db.exec(PUSH_SUBSCRIPTIONS_TABLE_SCHEMA_SQL);
db.exec("CREATE INDEX IF NOT EXISTS idx_push_subscriptions_user_id ON push_subscriptions(user_id)");
// Create session_names table if it doesn't exist (for existing installations)
db.exec(SESSION_NAMES_TABLE_SCHEMA_SQL);
db.exec("CREATE INDEX IF NOT EXISTS idx_session_names_lookup ON session_names(session_id, provider)");
// Create sessions table if it doesn't exist (for existing installations)
db.exec(SESSIONS_TABLE_SCHEMA_SQL);
db.exec(