forked from promptfoo/promptfoo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: migrate filesystem storage to sqlite db (promptfoo#558)
- Loading branch information
Showing
36 changed files
with
2,821 additions
and
440 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import 'dotenv/config'; | ||
import type { Config } from 'drizzle-kit'; | ||
|
||
export default { | ||
schema: './src/database.ts', | ||
out: './drizzle', | ||
driver: 'better-sqlite', | ||
} satisfies Config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
CREATE TABLE `datasets` ( | ||
`id` text PRIMARY KEY NOT NULL, | ||
`test_case_id` text NOT NULL, | ||
`created_at` integer DEFAULT CURRENT_TIMESTAMP NOT NULL | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE `evals` ( | ||
`id` text PRIMARY KEY NOT NULL, | ||
`created_at` integer DEFAULT CURRENT_TIMESTAMP NOT NULL, | ||
`description` text, | ||
`results` text NOT NULL, | ||
`config` text NOT NULL | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE `evals_to_datasets` ( | ||
`eval_id` text NOT NULL, | ||
`dataset_id` text NOT NULL, | ||
PRIMARY KEY(`dataset_id`, `eval_id`), | ||
FOREIGN KEY (`eval_id`) REFERENCES `evals`(`id`) ON UPDATE no action ON DELETE no action, | ||
FOREIGN KEY (`dataset_id`) REFERENCES `datasets`(`id`) ON UPDATE no action ON DELETE no action | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE `evals_to_prompts` ( | ||
`eval_id` text NOT NULL, | ||
`prompt_id` text NOT NULL, | ||
PRIMARY KEY(`eval_id`, `prompt_id`), | ||
FOREIGN KEY (`eval_id`) REFERENCES `evals`(`id`) ON UPDATE no action ON DELETE no action, | ||
FOREIGN KEY (`prompt_id`) REFERENCES `prompts`(`id`) ON UPDATE no action ON DELETE no action | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE `prompts` ( | ||
`id` text PRIMARY KEY NOT NULL, | ||
`created_at` integer DEFAULT CURRENT_TIMESTAMP NOT NULL, | ||
`prompt` text NOT NULL, | ||
`hash` text NOT NULL | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,244 @@ | ||
{ | ||
"version": "5", | ||
"dialect": "sqlite", | ||
"id": "8b53403f-5b6f-436a-862e-9fd17a52204e", | ||
"prevId": "00000000-0000-0000-0000-000000000000", | ||
"tables": { | ||
"datasets": { | ||
"name": "datasets", | ||
"columns": { | ||
"id": { | ||
"name": "id", | ||
"type": "text", | ||
"primaryKey": true, | ||
"notNull": true, | ||
"autoincrement": false | ||
}, | ||
"test_case_id": { | ||
"name": "test_case_id", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false | ||
}, | ||
"created_at": { | ||
"name": "created_at", | ||
"type": "integer", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false, | ||
"default": "CURRENT_TIMESTAMP" | ||
} | ||
}, | ||
"indexes": {}, | ||
"foreignKeys": {}, | ||
"compositePrimaryKeys": {}, | ||
"uniqueConstraints": {} | ||
}, | ||
"evals": { | ||
"name": "evals", | ||
"columns": { | ||
"id": { | ||
"name": "id", | ||
"type": "text", | ||
"primaryKey": true, | ||
"notNull": true, | ||
"autoincrement": false | ||
}, | ||
"created_at": { | ||
"name": "created_at", | ||
"type": "integer", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false, | ||
"default": "CURRENT_TIMESTAMP" | ||
}, | ||
"description": { | ||
"name": "description", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": false, | ||
"autoincrement": false | ||
}, | ||
"results": { | ||
"name": "results", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false | ||
}, | ||
"config": { | ||
"name": "config", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false | ||
} | ||
}, | ||
"indexes": {}, | ||
"foreignKeys": {}, | ||
"compositePrimaryKeys": {}, | ||
"uniqueConstraints": {} | ||
}, | ||
"evals_to_datasets": { | ||
"name": "evals_to_datasets", | ||
"columns": { | ||
"eval_id": { | ||
"name": "eval_id", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false | ||
}, | ||
"dataset_id": { | ||
"name": "dataset_id", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false | ||
} | ||
}, | ||
"indexes": {}, | ||
"foreignKeys": { | ||
"evals_to_datasets_eval_id_evals_id_fk": { | ||
"name": "evals_to_datasets_eval_id_evals_id_fk", | ||
"tableFrom": "evals_to_datasets", | ||
"tableTo": "evals", | ||
"columnsFrom": [ | ||
"eval_id" | ||
], | ||
"columnsTo": [ | ||
"id" | ||
], | ||
"onDelete": "no action", | ||
"onUpdate": "no action" | ||
}, | ||
"evals_to_datasets_dataset_id_datasets_id_fk": { | ||
"name": "evals_to_datasets_dataset_id_datasets_id_fk", | ||
"tableFrom": "evals_to_datasets", | ||
"tableTo": "datasets", | ||
"columnsFrom": [ | ||
"dataset_id" | ||
], | ||
"columnsTo": [ | ||
"id" | ||
], | ||
"onDelete": "no action", | ||
"onUpdate": "no action" | ||
} | ||
}, | ||
"compositePrimaryKeys": { | ||
"evals_to_datasets_eval_id_dataset_id_pk": { | ||
"columns": [ | ||
"dataset_id", | ||
"eval_id" | ||
], | ||
"name": "evals_to_datasets_eval_id_dataset_id_pk" | ||
} | ||
}, | ||
"uniqueConstraints": {} | ||
}, | ||
"evals_to_prompts": { | ||
"name": "evals_to_prompts", | ||
"columns": { | ||
"eval_id": { | ||
"name": "eval_id", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false | ||
}, | ||
"prompt_id": { | ||
"name": "prompt_id", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false | ||
} | ||
}, | ||
"indexes": {}, | ||
"foreignKeys": { | ||
"evals_to_prompts_eval_id_evals_id_fk": { | ||
"name": "evals_to_prompts_eval_id_evals_id_fk", | ||
"tableFrom": "evals_to_prompts", | ||
"tableTo": "evals", | ||
"columnsFrom": [ | ||
"eval_id" | ||
], | ||
"columnsTo": [ | ||
"id" | ||
], | ||
"onDelete": "no action", | ||
"onUpdate": "no action" | ||
}, | ||
"evals_to_prompts_prompt_id_prompts_id_fk": { | ||
"name": "evals_to_prompts_prompt_id_prompts_id_fk", | ||
"tableFrom": "evals_to_prompts", | ||
"tableTo": "prompts", | ||
"columnsFrom": [ | ||
"prompt_id" | ||
], | ||
"columnsTo": [ | ||
"id" | ||
], | ||
"onDelete": "no action", | ||
"onUpdate": "no action" | ||
} | ||
}, | ||
"compositePrimaryKeys": { | ||
"evals_to_prompts_eval_id_prompt_id_pk": { | ||
"columns": [ | ||
"eval_id", | ||
"prompt_id" | ||
], | ||
"name": "evals_to_prompts_eval_id_prompt_id_pk" | ||
} | ||
}, | ||
"uniqueConstraints": {} | ||
}, | ||
"prompts": { | ||
"name": "prompts", | ||
"columns": { | ||
"id": { | ||
"name": "id", | ||
"type": "text", | ||
"primaryKey": true, | ||
"notNull": true, | ||
"autoincrement": false | ||
}, | ||
"created_at": { | ||
"name": "created_at", | ||
"type": "integer", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false, | ||
"default": "CURRENT_TIMESTAMP" | ||
}, | ||
"prompt": { | ||
"name": "prompt", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false | ||
}, | ||
"hash": { | ||
"name": "hash", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false | ||
} | ||
}, | ||
"indexes": {}, | ||
"foreignKeys": {}, | ||
"compositePrimaryKeys": {}, | ||
"uniqueConstraints": {} | ||
} | ||
}, | ||
"enums": {}, | ||
"_meta": { | ||
"schemas": {}, | ||
"tables": {}, | ||
"columns": {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"version": "5", | ||
"dialect": "sqlite", | ||
"entries": [ | ||
{ | ||
"idx": 0, | ||
"version": "5", | ||
"when": 1710348564252, | ||
"tag": "0000_lush_hellion", | ||
"breakpoints": true | ||
} | ||
] | ||
} |
Oops, something went wrong.