SEC-cyBERT/labelapp/drizzle/0000_baseline.sql
2026-03-29 16:37:51 -04:00

75 lines
3.4 KiB
SQL

CREATE TABLE "adjudications" (
"paragraph_id" text PRIMARY KEY NOT NULL,
"final_category" text NOT NULL,
"final_specificity" integer NOT NULL,
"method" text NOT NULL,
"adjudicator_id" text,
"notes" text,
"resolved_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE "annotators" (
"id" text PRIMARY KEY NOT NULL,
"display_name" text NOT NULL,
"password" text NOT NULL,
"onboarded_at" timestamp
);
--> statement-breakpoint
CREATE TABLE "assignments" (
"paragraph_id" text NOT NULL,
"annotator_id" text NOT NULL,
"assigned_at" timestamp DEFAULT now() NOT NULL,
"is_warmup" boolean DEFAULT false NOT NULL,
CONSTRAINT "assignments_paragraph_id_annotator_id_unique" UNIQUE("paragraph_id","annotator_id")
);
--> statement-breakpoint
CREATE TABLE "human_labels" (
"id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "human_labels_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
"paragraph_id" text NOT NULL,
"annotator_id" text NOT NULL,
"content_category" text NOT NULL,
"specificity_level" integer NOT NULL,
"notes" text,
"labeled_at" timestamp DEFAULT now() NOT NULL,
"session_id" text NOT NULL,
"duration_ms" integer,
"active_ms" integer,
CONSTRAINT "human_labels_paragraph_id_annotator_id_unique" UNIQUE("paragraph_id","annotator_id")
);
--> statement-breakpoint
CREATE TABLE "paragraphs" (
"id" text PRIMARY KEY NOT NULL,
"text" text NOT NULL,
"word_count" integer NOT NULL,
"paragraph_index" integer NOT NULL,
"company_name" text NOT NULL,
"cik" text NOT NULL,
"ticker" text,
"filing_type" text NOT NULL,
"filing_date" text NOT NULL,
"fiscal_year" integer NOT NULL,
"accession_number" text NOT NULL,
"sec_item" text NOT NULL,
"stage1_category" text,
"stage1_specificity" integer,
"stage1_method" text,
"stage1_confidence" real
);
--> statement-breakpoint
CREATE TABLE "quiz_sessions" (
"id" text PRIMARY KEY NOT NULL,
"annotator_id" text NOT NULL,
"started_at" timestamp DEFAULT now() NOT NULL,
"completed_at" timestamp,
"passed" boolean DEFAULT false NOT NULL,
"score" integer DEFAULT 0 NOT NULL,
"total_questions" integer NOT NULL,
"answers" text DEFAULT '[]' NOT NULL
);
--> statement-breakpoint
ALTER TABLE "adjudications" ADD CONSTRAINT "adjudications_paragraph_id_paragraphs_id_fk" FOREIGN KEY ("paragraph_id") REFERENCES "public"."paragraphs"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "assignments" ADD CONSTRAINT "assignments_paragraph_id_paragraphs_id_fk" FOREIGN KEY ("paragraph_id") REFERENCES "public"."paragraphs"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "assignments" ADD CONSTRAINT "assignments_annotator_id_annotators_id_fk" FOREIGN KEY ("annotator_id") REFERENCES "public"."annotators"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "human_labels" ADD CONSTRAINT "human_labels_paragraph_id_paragraphs_id_fk" FOREIGN KEY ("paragraph_id") REFERENCES "public"."paragraphs"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "human_labels" ADD CONSTRAINT "human_labels_annotator_id_annotators_id_fk" FOREIGN KEY ("annotator_id") REFERENCES "public"."annotators"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "quiz_sessions" ADD CONSTRAINT "quiz_sessions_annotator_id_annotators_id_fk" FOREIGN KEY ("annotator_id") REFERENCES "public"."annotators"("id") ON DELETE no action ON UPDATE no action;