Add database migration for secrets detection columns
authormaximiliancw <redacted>
Fri, 9 Jan 2026 15:23:47 +0000 (16:23 +0100)
committermaximiliancw <redacted>
Fri, 9 Jan 2026 15:23:47 +0000 (16:23 +0100)
Existing installations will fail with 'table request_logs has no column
named secrets_detected' since the new columns don't exist in their SQLite
database. This adds a migration check that adds the missing columns if they
don't exist.

src/services/logger.ts

index 941778ec89dd28f54b2a274faf35a2edc9bd097d..0c7e0faf55bd49baa0510b79d1f781c9701ef990 100644 (file)
@@ -84,6 +84,15 @@ export class Logger {
       )
     `);
 
+    // Migrate existing databases: add secrets columns if missing
+    const columns = this.db.prepare("PRAGMA table_info(request_logs)").all() as Array<{
+      name: string;
+    }>;
+    if (!columns.find((c) => c.name === "secrets_detected")) {
+      this.db.run("ALTER TABLE request_logs ADD COLUMN secrets_detected INTEGER");
+      this.db.run("ALTER TABLE request_logs ADD COLUMN secrets_types TEXT");
+    }
+
     // Create indexes for performance
     this.db.run(`
       CREATE INDEX IF NOT EXISTS idx_timestamp ON request_logs(timestamp)
git clone https://git.99rst.org/PROJECT