feat: add database schema, migrations, and API endpoints for span annotations
- Add span_label_types and span_annotations tables to schema - Seed default span label types (bull_flag, bear_flag, etc.) - Implement CRUD API endpoints for span label types - Implement CRUD API endpoints for span annotations - Add time swap validation in POST endpoint (start_time <= end_time)
This commit is contained in:
parent
8a7eb1fb08
commit
dadf515406
11 changed files with 1131 additions and 0 deletions
27
drizzle/0003_demonic_captain_flint.sql
Normal file
27
drizzle/0003_demonic_captain_flint.sql
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
CREATE TABLE `span_annotations` (
|
||||
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
`chart_id` integer NOT NULL,
|
||||
`start_time` integer NOT NULL,
|
||||
`end_time` integer NOT NULL,
|
||||
`label` text NOT NULL,
|
||||
`confidence` integer,
|
||||
`outcome` text,
|
||||
`notes` text,
|
||||
`sub_spans` text,
|
||||
`color` text DEFAULT '#2196F3' NOT NULL,
|
||||
`created_at` integer NOT NULL,
|
||||
FOREIGN KEY (`chart_id`) REFERENCES `charts`(`id`) ON UPDATE no action ON DELETE no action
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `span_label_types` (
|
||||
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
`name` text NOT NULL,
|
||||
`display_name` text NOT NULL,
|
||||
`color` text NOT NULL,
|
||||
`hotkey` text,
|
||||
`is_active` integer DEFAULT 1 NOT NULL,
|
||||
`sort_order` integer DEFAULT 0 NOT NULL,
|
||||
`created_at` integer NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX `span_label_types_name_unique` ON `span_label_types` (`name`);
|
||||
Loading…
Add table
Add a link
Reference in a new issue