Bündelt die Neuentwicklung in AssigmentMonitorV2 (eigene Ports/DB), die Umstellung auf numerische Bewertungen, Meeting-Checklisten, KI-Tagging und die geplante Feedback-Kaskade — als Basis für Versionsverwaltung in Gitea. Co-authored-by: Cursor <cursoragent@cursor.com>
43 lines
1.7 KiB
TypeScript
43 lines
1.7 KiB
TypeScript
/**
|
|
* Setzt NUR die V2-Dev-Datenbank zurück (löscht die Datei unter server/data/).
|
|
* Produktiv (c:\dev\AssigmentMonitor) wird nicht angefasst — gleiche Pfad-Guards wie database.ts.
|
|
*
|
|
* Usage: npm run db:reset
|
|
*/
|
|
import { existsSync, unlinkSync } from 'node:fs'
|
|
import { dirname, join, resolve, sep } from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
const projectRoot = resolve(join(__dirname, '../..'))
|
|
const sqliteFilename = process.env.SQLITE_FILENAME?.trim() || 'assignment-monitor-v2-dev.sqlite3'
|
|
|
|
if (sqliteFilename.includes('/') || sqliteFilename.includes('\\') || sqliteFilename.includes('..')) {
|
|
throw new Error(`[db:reset] SAFETY: SQLITE_FILENAME ungültig: "${sqliteFilename}"`)
|
|
}
|
|
|
|
const dbPath = resolve(join(__dirname, '..', 'data', sqliteFilename))
|
|
const dbNorm = dbPath.toLowerCase()
|
|
const rootNorm = projectRoot.toLowerCase()
|
|
const rootPrefix = rootNorm.endsWith(sep) ? rootNorm : rootNorm + sep
|
|
|
|
if (!dbNorm.startsWith(rootPrefix)) {
|
|
throw new Error(`[db:reset] SAFETY: Pfad außerhalb V2: ${dbPath}`)
|
|
}
|
|
if (
|
|
/[/\\]assigmentmonitor[/\\]server[/\\]data[/\\]/.test(dbNorm) &&
|
|
!/[/\\]assigmentmonitorv2[/\\]/.test(dbNorm)
|
|
) {
|
|
throw new Error(`[db:reset] SAFETY: Produktiv-DB blockiert: ${dbPath}`)
|
|
}
|
|
|
|
if (!existsSync(dbPath)) {
|
|
console.log(`[db:reset] Keine Datei vorhanden — nichts zu löschen:\n ${dbPath}`)
|
|
console.log(`[db:reset] Beim nächsten Server-Start wird eine leere DB angelegt.`)
|
|
process.exit(0)
|
|
}
|
|
|
|
unlinkSync(dbPath)
|
|
console.log(`[db:reset] Dev-DB gelöscht:\n ${dbPath}`)
|
|
console.log(`[db:reset] Beim nächsten \`npm run server\` / \`npm run dev:all\` wird eine frische DB erzeugt.`)
|