Skip to content

Commit

Permalink
fix: resolve foreign key constraint in deleteAllEvals (promptfoo#1581)
Browse files Browse the repository at this point in the history
  • Loading branch information
mldangelo authored Sep 4, 2024
1 parent 8be6447 commit 3f7e426
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"Dedup",
"deduped",
"envars",
"Evals",
"Groq",
"mitigations",
"openai",
Expand Down
14 changes: 12 additions & 2 deletions src/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -921,9 +921,19 @@ export async function deleteEval(evalId: string) {
});
}

export async function deleteAllEvals() {
/**
* Deletes all evaluations and related records with foreign keys from the database.
* @async
* @returns {Promise<void>}
*/
export async function deleteAllEvals(): Promise<void> {
const db = getDb();
await db.delete(evals).run();
await db.transaction(async (tx) => {
await tx.delete(evalsToPrompts).run();
await tx.delete(evalsToDatasets).run();
await tx.delete(evalsToTags).run();
await tx.delete(evals).run();
});
}

export async function readFilters(
Expand Down

0 comments on commit 3f7e426

Please sign in to comment.