fix: 安全性与代码质量加固(异常保护、外键级联、竞态修复、优雅关机)
This commit is contained in:
@@ -26,7 +26,7 @@ CREATE TABLE IF NOT EXISTS check_results (
|
||||
duration_ms REAL,
|
||||
status_detail TEXT,
|
||||
failure TEXT,
|
||||
FOREIGN KEY (target_id) REFERENCES targets(id)
|
||||
FOREIGN KEY (target_id) REFERENCES targets(id) ON DELETE CASCADE
|
||||
)
|
||||
`;
|
||||
|
||||
@@ -43,6 +43,7 @@ export class ProbeStore {
|
||||
ensureDir(dirname(dbPath));
|
||||
this.db = new Database(dbPath, { create: true });
|
||||
this.db.run("PRAGMA journal_mode = WAL");
|
||||
this.db.run("PRAGMA foreign_keys = ON");
|
||||
this.db.run(CREATE_TARGETS_TABLE);
|
||||
this.db.run(CREATE_CHECK_RESULTS_TABLE);
|
||||
this.db.run(CREATE_INDEX);
|
||||
|
||||
Reference in New Issue
Block a user