1CREATE TABLE "messages" (
2 "id" serial PRIMARY KEY NOT NULL,
3 "thread_id" integer NOT NULL,
4 "role" text NOT NULL,
5 "content" text NOT NULL,
6 "created_at" timestamp with time zone DEFAULT now() NOT NULL,
7 "generation_time_ms" integer,
8 "tool_calls" text
9);
10--> statement-breakpoint
11CREATE TABLE "threads" (
12 "id" serial PRIMARY KEY NOT NULL,
13 "title" text,
14 "created_at" timestamp with time zone DEFAULT now() NOT NULL,
15 "updated_at" timestamp with time zone DEFAULT now() NOT NULL
16);
17--> statement-breakpoint
18ALTER TABLE "messages" ADD CONSTRAINT "messages_thread_id_threads_id_fk" FOREIGN KEY ("thread_id") REFERENCES "public"."threads"("id") ON DELETE cascade ON UPDATE no action;