An AI-powered search engine with a generative UI
TypeScript generative-aigenerative-uinextjsollamareactsearxngshadcn-uitailwindcsstavilytypescriptupstashvercel-ai-sdk
feat: migrate database from Supabase to Neon DB
Yoshiki Miura17c21ea71831
diff --git a/.env.local.example b/.env.local.exampleindex fcdcd180..8ab27757 100644--- a/.env.local.example+++ b/.env.local.example@@ -93,6 +93,12 @@ TAVILY_API_KEY=[YOUR_TAVILY_API_KEY] # Get your API key at: https://app.tavily.# SERPER_API_KEY=[YOUR_SERPER_API_KEY] # Enable video search capability# JINA_API_KEY=[YOUR_JINA_API_KEY] # Alternative to Tavily for retrieve tool+# ------------------------------+# Database Configuration+# ------------------------------+# PostgreSQL connection string for Neon DB+# Format: postgresql://[user]:[password]@[host]/[database]?sslmode=require+DATABASE_URL=[YOUR_NEON_DATABASE_URL]# ------------------------------# Supabase Configuration (Auth)diff --git a/drizzle/0000_melodic_unicorn.sql b/drizzle/0000_melodic_unicorn.sqldeleted file mode 100644index 245faaad..00000000--- a/drizzle/0000_melodic_unicorn.sql+++ /dev/null@@ -1,19 +0,0 @@-CREATE TABLE "chats" (- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,- "created_at" timestamp with time zone DEFAULT now() NOT NULL,- "updated_at" timestamp with time zone DEFAULT now() NOT NULL,- "title" text NOT NULL,- "user_id" uuid NOT NULL,- "visibility" varchar(256) DEFAULT 'private' NOT NULL-);---> statement-breakpoint-CREATE TABLE "messages" (- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,- "chat_id" uuid NOT NULL,- "role" varchar(256) NOT NULL,- "parts" json NOT NULL,- "created_at" timestamp with time zone DEFAULT now() NOT NULL,- "updated_at" timestamp with time zone DEFAULT now() NOT NULL-);---> statement-breakpoint-ALTER TABLE "messages" ADD CONSTRAINT "messages_chat_id_chats_id_fk" FOREIGN KEY ("chat_id") REFERENCES "public"."chats"("id") ON DELETE cascade ON UPDATE no action;\ No newline at end of filediff --git a/drizzle/0001_busy_katie_power.sql b/drizzle/0000_perfect_ares.sqlsimilarity index 71%rename from drizzle/0001_busy_katie_power.sqlrename to drizzle/0000_perfect_ares.sqlindex a7797928..fac79927 100644--- a/drizzle/0001_busy_katie_power.sql+++ b/drizzle/0000_perfect_ares.sql@@ -1,6 +1,21 @@+CREATE TABLE "chats" (+ "id" varchar(191) PRIMARY KEY NOT NULL,+ "created_at" timestamp DEFAULT now() NOT NULL,+ "title" text NOT NULL,+ "user_id" varchar(255) NOT NULL,+ "visibility" varchar(256) DEFAULT 'private' NOT NULL+);+--> statement-breakpoint+CREATE TABLE "messages" (+ "id" varchar(191) PRIMARY KEY NOT NULL,+ "chat_id" varchar(191) NOT NULL,+ "role" varchar(256) NOT NULL,+ "created_at" timestamp DEFAULT now() NOT NULL+);+--> statement-breakpointCREATE TABLE "parts" (- "id" varchar PRIMARY KEY NOT NULL,- "message_id" varchar NOT NULL,+ "id" varchar(191) PRIMARY KEY NOT NULL,+ "message_id" varchar(191) NOT NULL,"order" integer NOT NULL,"type" varchar(256) NOT NULL,"text_text" text,@@ -28,13 +43,15 @@ CREATE TABLE "parts" ("tool_question_output" json,"tool_video_search_input" json,"tool_video_search_output" json,+ "tool_related_questions_input" json,+ "tool_related_questions_output" json,"tool_mcp_input" json,"tool_mcp_output" json,"data_prefix" varchar(256),"data_content" json,"data_id" varchar(256),"provider_metadata" json,- "created_at" timestamp with time zone DEFAULT now() NOT NULL,+ "created_at" timestamp DEFAULT now() NOT NULL,CONSTRAINT "text_text_required" CHECK ((type != 'text' OR text_text IS NOT NULL)),CONSTRAINT "reasoning_text_required" CHECK ((type != 'reasoning' OR reasoning_text IS NOT NULL)),CONSTRAINT "file_fields_required" CHECK ((type != 'file' OR (file_media_type IS NOT NULL AND file_filename IS NOT NULL AND file_url IS NOT NULL))),@@ -42,17 +59,9 @@ CREATE TABLE "parts" (CONSTRAINT "tool_fields_required" CHECK ((type NOT LIKE 'tool-%' OR (tool_tool_call_id IS NOT NULL AND tool_state IS NOT NULL))));--> statement-breakpoint-ALTER TABLE "chats" ALTER COLUMN "id" SET DATA TYPE varchar;--> statement-breakpoint-ALTER TABLE "chats" ALTER COLUMN "id" DROP DEFAULT;--> statement-breakpoint-ALTER TABLE "chats" ALTER COLUMN "user_id" SET DATA TYPE varchar;--> statement-breakpoint-ALTER TABLE "messages" ALTER COLUMN "id" SET DATA TYPE varchar;--> statement-breakpoint-ALTER TABLE "messages" ALTER COLUMN "id" DROP DEFAULT;--> statement-breakpoint-ALTER TABLE "messages" ALTER COLUMN "chat_id" SET DATA TYPE varchar;--> statement-breakpoint+ALTER TABLE "messages" ADD CONSTRAINT "messages_chat_id_chats_id_fk" FOREIGN KEY ("chat_id") REFERENCES "public"."chats"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpointALTER TABLE "parts" ADD CONSTRAINT "parts_message_id_messages_id_fk" FOREIGN KEY ("message_id") REFERENCES "public"."messages"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint-CREATE INDEX "parts_message_id_idx" ON "parts" USING btree ("message_id");--> statement-breakpoint-CREATE INDEX "parts_message_id_order_idx" ON "parts" USING btree ("message_id","order");--> statement-breakpointCREATE INDEX "messages_chat_id_idx" ON "messages" USING btree ("chat_id");--> statement-breakpointCREATE INDEX "messages_chat_id_created_at_idx" ON "messages" USING btree ("chat_id","created_at");--> statement-breakpoint-ALTER TABLE "chats" DROP COLUMN "updated_at";--> statement-breakpoint-ALTER TABLE "messages" DROP COLUMN "parts";--> statement-breakpoint-ALTER TABLE "messages" DROP COLUMN "updated_at";\ No newline at end of file+CREATE INDEX "parts_message_id_idx" ON "parts" USING btree ("message_id");--> statement-breakpoint+CREATE INDEX "parts_message_id_order_idx" ON "parts" USING btree ("message_id","order");\ No newline at end of filediff --git a/drizzle/0002_add_related_questions_columns.sql b/drizzle/0002_add_related_questions_columns.sqldeleted file mode 100644index 6114b25c..00000000--- a/drizzle/0002_add_related_questions_columns.sql+++ /dev/null@@ -1,3 +0,0 @@--- Add columns for relatedQuestions tool-ALTER TABLE parts ADD COLUMN tool_related_questions_input json;-ALTER TABLE parts ADD COLUMN tool_related_questions_output json;\ No newline at end of filediff --git a/drizzle/0003_optimize_schema_types.sql b/drizzle/0003_optimize_schema_types.sqldeleted file mode 100644index bcae5ce1..00000000--- a/drizzle/0003_optimize_schema_types.sql+++ /dev/null@@ -1,15 +0,0 @@--- Optimize schema to match Vercel's implementation--- Note: These changes affect column types only, not the actual data---- Update varchar length constraints-ALTER TABLE chats ALTER COLUMN id TYPE varchar(191);-ALTER TABLE chats ALTER COLUMN user_id TYPE varchar(255);--ALTER TABLE messages ALTER COLUMN id TYPE varchar(191);-ALTER TABLE messages ALTER COLUMN chat_id TYPE varchar(191);--ALTER TABLE parts ALTER COLUMN id TYPE varchar(191);-ALTER TABLE parts ALTER COLUMN message_id TYPE varchar(191);---- Note: Timestamp columns remain unchanged as PostgreSQL handles them appropriately--- The mode change from 'string' to 'date' is handled at the application level\ No newline at end of filediff --git a/drizzle/meta/0000_snapshot.json b/drizzle/meta/0000_snapshot.jsonindex 576ccb53..eb70d28e 100644--- a/drizzle/meta/0000_snapshot.json+++ b/drizzle/meta/0000_snapshot.json@@ -1,5 +1,5 @@{- "id": "93a8bb81-9754-43af-8fb2-abbedc59c89b",+ "id": "c2116538-2854-48c0-b309-32cd2fb28e62","prevId": "00000000-0000-0000-0000-000000000000","version": "7","dialect": "postgresql",@@ -10,21 +10,13 @@"columns": {"id": {"name": "id",- "type": "uuid",+ "type": "varchar(191)","primaryKey": true,- "notNull": true,- "default": "gen_random_uuid()"+ "notNull": true},"created_at": {"name": "created_at",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": true,- "default": "now()"- },- "updated_at": {- "name": "updated_at",- "type": "timestamp with time zone",+ "type": "timestamp","primaryKey": false,"notNull": true,"default": "now()"@@ -37,7 +29,7 @@},"user_id": {"name": "user_id",- "type": "uuid",+ "type": "varchar(255)","primaryKey": false,"notNull": true},@@ -63,14 +55,13 @@"columns": {"id": {"name": "id",- "type": "uuid",+ "type": "varchar(191)","primaryKey": true,- "notNull": true,- "default": "gen_random_uuid()"+ "notNull": true},"chat_id": {"name": "chat_id",- "type": "uuid",+ "type": "varchar(191)","primaryKey": false,"notNull": true},@@ -80,35 +71,63 @@"primaryKey": false,"notNull": true},- "parts": {- "name": "parts",- "type": "json",- "primaryKey": false,- "notNull": true- },"created_at": {"name": "created_at",- "type": "timestamp with time zone",+ "type": "timestamp","primaryKey": false,"notNull": true,"default": "now()"+ }+ },+ "indexes": {+ "messages_chat_id_idx": {+ "name": "messages_chat_id_idx",+ "columns": [+ {+ "expression": "chat_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}},- "updated_at": {- "name": "updated_at",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": true,- "default": "now()"+ "messages_chat_id_created_at_idx": {+ "name": "messages_chat_id_created_at_idx",+ "columns": [+ {+ "expression": "chat_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}}},- "indexes": {},"foreignKeys": {"messages_chat_id_chats_id_fk": {"name": "messages_chat_id_chats_id_fk","tableFrom": "messages","tableTo": "chats",- "columnsFrom": ["chat_id"],- "columnsTo": ["id"],+ "columnsFrom": [+ "chat_id"+ ],+ "columnsTo": [+ "id"+ ],"onDelete": "cascade","onUpdate": "no action"}@@ -118,6 +137,320 @@"policies": {},"checkConstraints": {},"isRLSEnabled": false+ },+ "public.parts": {+ "name": "parts",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(191)",+ "primaryKey": true,+ "notNull": true+ },+ "message_id": {+ "name": "message_id",+ "type": "varchar(191)",+ "primaryKey": false,+ "notNull": true+ },+ "order": {+ "name": "order",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "type": {+ "name": "type",+ "type": "varchar(256)",+ "primaryKey": false,+ "notNull": true+ },+ "text_text": {+ "name": "text_text",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "reasoning_text": {+ "name": "reasoning_text",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "file_media_type": {+ "name": "file_media_type",+ "type": "varchar(256)",+ "primaryKey": false,+ "notNull": false+ },+ "file_filename": {+ "name": "file_filename",+ "type": "varchar(1024)",+ "primaryKey": false,+ "notNull": false+ },+ "file_url": {+ "name": "file_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "source_url_source_id": {+ "name": "source_url_source_id",+ "type": "varchar(256)",+ "primaryKey": false,+ "notNull": false+ },+ "source_url_url": {+ "name": "source_url_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "source_url_title": {+ "name": "source_url_title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "source_document_source_id": {+ "name": "source_document_source_id",+ "type": "varchar(256)",+ "primaryKey": false,+ "notNull": false+ },+ "source_document_media_type": {+ "name": "source_document_media_type",+ "type": "varchar(256)",+ "primaryKey": false,+ "notNull": false+ },+ "source_document_title": {+ "name": "source_document_title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "source_document_filename": {+ "name": "source_document_filename",+ "type": "varchar(1024)",+ "primaryKey": false,+ "notNull": false+ },+ "source_document_url": {+ "name": "source_document_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "source_document_snippet": {+ "name": "source_document_snippet",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "tool_tool_call_id": {+ "name": "tool_tool_call_id",+ "type": "varchar(256)",+ "primaryKey": false,+ "notNull": false+ },+ "tool_state": {+ "name": "tool_state",+ "type": "varchar(256)",+ "primaryKey": false,+ "notNull": false+ },+ "tool_error_text": {+ "name": "tool_error_text",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "tool_search_input": {+ "name": "tool_search_input",+ "type": "json",+ "primaryKey": false,+ "notNull": false+ },+ "tool_search_output": {+ "name": "tool_search_output",+ "type": "json",+ "primaryKey": false,+ "notNull": false+ },+ "tool_retrieve_input": {+ "name": "tool_retrieve_input",+ "type": "json",+ "primaryKey": false,+ "notNull": false+ },+ "tool_retrieve_output": {+ "name": "tool_retrieve_output",+ "type": "json",+ "primaryKey": false,+ "notNull": false+ },+ "tool_question_input": {+ "name": "tool_question_input",+ "type": "json",+ "primaryKey": false,+ "notNull": false+ },+ "tool_question_output": {+ "name": "tool_question_output",+ "type": "json",+ "primaryKey": false,+ "notNull": false+ },+ "tool_video_search_input": {+ "name": "tool_video_search_input",+ "type": "json",+ "primaryKey": false,+ "notNull": false+ },+ "tool_video_search_output": {+ "name": "tool_video_search_output",+ "type": "json",+ "primaryKey": false,+ "notNull": false+ },+ "tool_related_questions_input": {+ "name": "tool_related_questions_input",+ "type": "json",+ "primaryKey": false,+ "notNull": false+ },+ "tool_related_questions_output": {+ "name": "tool_related_questions_output",+ "type": "json",+ "primaryKey": false,+ "notNull": false+ },+ "tool_mcp_input": {+ "name": "tool_mcp_input",+ "type": "json",+ "primaryKey": false,+ "notNull": false+ },+ "tool_mcp_output": {+ "name": "tool_mcp_output",+ "type": "json",+ "primaryKey": false,+ "notNull": false+ },+ "data_prefix": {+ "name": "data_prefix",+ "type": "varchar(256)",+ "primaryKey": false,+ "notNull": false+ },+ "data_content": {+ "name": "data_content",+ "type": "json",+ "primaryKey": false,+ "notNull": false+ },+ "data_id": {+ "name": "data_id",+ "type": "varchar(256)",+ "primaryKey": false,+ "notNull": false+ },+ "provider_metadata": {+ "name": "provider_metadata",+ "type": "json",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "parts_message_id_idx": {+ "name": "parts_message_id_idx",+ "columns": [+ {+ "expression": "message_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "parts_message_id_order_idx": {+ "name": "parts_message_id_order_idx",+ "columns": [+ {+ "expression": "message_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "order",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "parts_message_id_messages_id_fk": {+ "name": "parts_message_id_messages_id_fk",+ "tableFrom": "parts",+ "tableTo": "messages",+ "columnsFrom": [+ "message_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "text_text_required": {+ "name": "text_text_required",+ "value": "(type != 'text' OR text_text IS NOT NULL)"+ },+ "reasoning_text_required": {+ "name": "reasoning_text_required",+ "value": "(type != 'reasoning' OR reasoning_text IS NOT NULL)"+ },+ "file_fields_required": {+ "name": "file_fields_required",+ "value": "(type != 'file' OR (file_media_type IS NOT NULL AND file_filename IS NOT NULL AND file_url IS NOT NULL))"+ },+ "tool_state_valid": {+ "name": "tool_state_valid",+ "value": "(tool_state IS NULL OR tool_state IN ('input-streaming', 'input-available', 'output-available', 'output-error'))"+ },+ "tool_fields_required": {+ "name": "tool_fields_required",+ "value": "(type NOT LIKE 'tool-%' OR (tool_tool_call_id IS NOT NULL AND tool_state IS NOT NULL))"+ }+ },+ "isRLSEnabled": false}},"enums": {},@@ -131,4 +464,4 @@"schemas": {},"tables": {}}-}+}\ No newline at end of filediff --git a/drizzle/meta/0001_snapshot.json b/drizzle/meta/0001_snapshot.jsondeleted file mode 100644index 5e04af1a..00000000--- a/drizzle/meta/0001_snapshot.json+++ /dev/null@@ -1,447 +0,0 @@-{- "id": "d4c5910e-59c9-4189-b010-22838368df2b",- "prevId": "93a8bb81-9754-43af-8fb2-abbedc59c89b",- "version": "7",- "dialect": "postgresql",- "tables": {- "public.chats": {- "name": "chats",- "schema": "",- "columns": {- "id": {- "name": "id",- "type": "varchar",- "primaryKey": true,- "notNull": true- },- "created_at": {- "name": "created_at",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": true,- "default": "now()"- },- "title": {- "name": "title",- "type": "text",- "primaryKey": false,- "notNull": true- },- "user_id": {- "name": "user_id",- "type": "varchar",- "primaryKey": false,- "notNull": true- },- "visibility": {- "name": "visibility",- "type": "varchar(256)",- "primaryKey": false,- "notNull": true,- "default": "'private'"- }- },- "indexes": {},- "foreignKeys": {},- "compositePrimaryKeys": {},- "uniqueConstraints": {},- "policies": {},- "checkConstraints": {},- "isRLSEnabled": false- },- "public.messages": {- "name": "messages",- "schema": "",- "columns": {- "id": {- "name": "id",- "type": "varchar",- "primaryKey": true,- "notNull": true- },- "chat_id": {- "name": "chat_id",- "type": "varchar",- "primaryKey": false,- "notNull": true- },- "role": {- "name": "role",- "type": "varchar(256)",- "primaryKey": false,- "notNull": true- },- "created_at": {- "name": "created_at",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": true,- "default": "now()"- }- },- "indexes": {- "messages_chat_id_idx": {- "name": "messages_chat_id_idx",- "columns": [- {- "expression": "chat_id",- "isExpression": false,- "asc": true,- "nulls": "last"- }- ],- "isUnique": false,- "concurrently": false,- "method": "btree",- "with": {}- },- "messages_chat_id_created_at_idx": {- "name": "messages_chat_id_created_at_idx",- "columns": [- {- "expression": "chat_id",- "isExpression": false,- "asc": true,- "nulls": "last"- },- {- "expression": "created_at",- "isExpression": false,- "asc": true,- "nulls": "last"- }- ],- "isUnique": false,- "concurrently": false,- "method": "btree",- "with": {}- }- },- "foreignKeys": {- "messages_chat_id_chats_id_fk": {- "name": "messages_chat_id_chats_id_fk",- "tableFrom": "messages",- "tableTo": "chats",- "columnsFrom": ["chat_id"],- "columnsTo": ["id"],- "onDelete": "cascade",- "onUpdate": "no action"- }- },- "compositePrimaryKeys": {},- "uniqueConstraints": {},- "policies": {},- "checkConstraints": {},- "isRLSEnabled": false- },- "public.parts": {- "name": "parts",- "schema": "",- "columns": {- "id": {- "name": "id",- "type": "varchar",- "primaryKey": true,- "notNull": true- },- "message_id": {- "name": "message_id",- "type": "varchar",- "primaryKey": false,- "notNull": true- },- "order": {- "name": "order",- "type": "integer",- "primaryKey": false,- "notNull": true- },- "type": {- "name": "type",- "type": "varchar(256)",- "primaryKey": false,- "notNull": true- },- "text_text": {- "name": "text_text",- "type": "text",- "primaryKey": false,- "notNull": false- },- "reasoning_text": {- "name": "reasoning_text",- "type": "text",- "primaryKey": false,- "notNull": false- },- "file_media_type": {- "name": "file_media_type",- "type": "varchar(256)",- "primaryKey": false,- "notNull": false- },- "file_filename": {- "name": "file_filename",- "type": "varchar(1024)",- "primaryKey": false,- "notNull": false- },- "file_url": {- "name": "file_url",- "type": "text",- "primaryKey": false,- "notNull": false- },- "source_url_source_id": {- "name": "source_url_source_id",- "type": "varchar(256)",- "primaryKey": false,- "notNull": false- },- "source_url_url": {- "name": "source_url_url",- "type": "text",- "primaryKey": false,- "notNull": false- },- "source_url_title": {- "name": "source_url_title",- "type": "text",- "primaryKey": false,- "notNull": false- },- "source_document_source_id": {- "name": "source_document_source_id",- "type": "varchar(256)",- "primaryKey": false,- "notNull": false- },- "source_document_media_type": {- "name": "source_document_media_type",- "type": "varchar(256)",- "primaryKey": false,- "notNull": false- },- "source_document_title": {- "name": "source_document_title",- "type": "text",- "primaryKey": false,- "notNull": false- },- "source_document_filename": {- "name": "source_document_filename",- "type": "varchar(1024)",- "primaryKey": false,- "notNull": false- },- "source_document_url": {- "name": "source_document_url",- "type": "text",- "primaryKey": false,- "notNull": false- },- "source_document_snippet": {- "name": "source_document_snippet",- "type": "text",- "primaryKey": false,- "notNull": false- },- "tool_tool_call_id": {- "name": "tool_tool_call_id",- "type": "varchar(256)",- "primaryKey": false,- "notNull": false- },- "tool_state": {- "name": "tool_state",- "type": "varchar(256)",- "primaryKey": false,- "notNull": false- },- "tool_error_text": {- "name": "tool_error_text",- "type": "text",- "primaryKey": false,- "notNull": false- },- "tool_search_input": {- "name": "tool_search_input",- "type": "json",- "primaryKey": false,- "notNull": false- },- "tool_search_output": {- "name": "tool_search_output",- "type": "json",- "primaryKey": false,- "notNull": false- },- "tool_retrieve_input": {- "name": "tool_retrieve_input",- "type": "json",- "primaryKey": false,- "notNull": false- },- "tool_retrieve_output": {- "name": "tool_retrieve_output",- "type": "json",- "primaryKey": false,- "notNull": false- },- "tool_question_input": {- "name": "tool_question_input",- "type": "json",- "primaryKey": false,- "notNull": false- },- "tool_question_output": {- "name": "tool_question_output",- "type": "json",- "primaryKey": false,- "notNull": false- },- "tool_video_search_input": {- "name": "tool_video_search_input",- "type": "json",- "primaryKey": false,- "notNull": false- },- "tool_video_search_output": {- "name": "tool_video_search_output",- "type": "json",- "primaryKey": false,- "notNull": false- },- "tool_mcp_input": {- "name": "tool_mcp_input",- "type": "json",- "primaryKey": false,- "notNull": false- },- "tool_mcp_output": {- "name": "tool_mcp_output",- "type": "json",- "primaryKey": false,- "notNull": false- },- "data_prefix": {- "name": "data_prefix",- "type": "varchar(256)",- "primaryKey": false,- "notNull": false- },- "data_content": {- "name": "data_content",- "type": "json",- "primaryKey": false,- "notNull": false- },- "data_id": {- "name": "data_id",- "type": "varchar(256)",- "primaryKey": false,- "notNull": false- },- "provider_metadata": {- "name": "provider_metadata",- "type": "json",- "primaryKey": false,- "notNull": false- },- "created_at": {- "name": "created_at",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": true,- "default": "now()"- }- },- "indexes": {- "parts_message_id_idx": {- "name": "parts_message_id_idx",- "columns": [- {- "expression": "message_id",- "isExpression": false,- "asc": true,- "nulls": "last"- }- ],- "isUnique": false,- "concurrently": false,- "method": "btree",- "with": {}- },- "parts_message_id_order_idx": {- "name": "parts_message_id_order_idx",- "columns": [- {- "expression": "message_id",- "isExpression": false,- "asc": true,- "nulls": "last"- },- {- "expression": "order",- "isExpression": false,- "asc": true,- "nulls": "last"- }- ],- "isUnique": false,- "concurrently": false,- "method": "btree",- "with": {}- }- },- "foreignKeys": {- "parts_message_id_messages_id_fk": {- "name": "parts_message_id_messages_id_fk",- "tableFrom": "parts",- "tableTo": "messages",- "columnsFrom": ["message_id"],- "columnsTo": ["id"],- "onDelete": "cascade",- "onUpdate": "no action"- }- },- "compositePrimaryKeys": {},- "uniqueConstraints": {},- "policies": {},- "checkConstraints": {- "text_text_required": {- "name": "text_text_required",- "value": "(type != 'text' OR text_text IS NOT NULL)"- },- "reasoning_text_required": {- "name": "reasoning_text_required",- "value": "(type != 'reasoning' OR reasoning_text IS NOT NULL)"- },- "file_fields_required": {- "name": "file_fields_required",- "value": "(type != 'file' OR (file_media_type IS NOT NULL AND file_filename IS NOT NULL AND file_url IS NOT NULL))"- },- "tool_state_valid": {- "name": "tool_state_valid",- "value": "(tool_state IS NULL OR tool_state IN ('input-streaming', 'input-available', 'output-available', 'output-error'))"- },- "tool_fields_required": {- "name": "tool_fields_required",- "value": "(type NOT LIKE 'tool-%' OR (tool_tool_call_id IS NOT NULL AND tool_state IS NOT NULL))"- }- },- "isRLSEnabled": false- }- },- "enums": {},- "schemas": {},- "sequences": {},- "roles": {},- "policies": {},- "views": {},- "_meta": {- "columns": {},- "schemas": {},- "tables": {}- }-}diff --git a/drizzle/meta/0002_snapshot.json b/drizzle/meta/0002_snapshot.jsondeleted file mode 100644index 4c9d178b..00000000--- a/drizzle/meta/0002_snapshot.json+++ /dev/null@@ -1,540 +0,0 @@-{- "id": "00000000-0000-0000-0000-000000000002",- "prevId": "00000000-0000-0000-0000-000000000001",- "version": "7",- "dialect": "postgresql",- "tables": {- "public.chats": {- "name": "chats",- "schema": "",- "columns": {- "id": {- "name": "id",- "type": "varchar(191)",- "primaryKey": false,- "notNull": true,- "default": ""- },- "title": {- "name": "title",- "type": "text",- "primaryKey": false,- "notNull": true,- "default": ""- },- "user_id": {- "name": "user_id",- "type": "varchar(255)",- "primaryKey": false,- "notNull": true,- "default": ""- },- "visibility": {- "name": "visibility",- "type": "visibility_type",- "typeSchema": "public",- "primaryKey": false,- "notNull": false,- "default": "'private'"- },- "created_at": {- "name": "created_at",- "type": "timestamp",- "primaryKey": false,- "notNull": true,- "default": "now()"- },- "updated_at": {- "name": "updated_at",- "type": "timestamp",- "primaryKey": false,- "notNull": true,- "default": "now()"- }- },- "indexes": {- "chats_user_id_idx": {- "name": "chats_user_id_idx",- "columns": [- {- "expression": "user_id",- "isExpression": false,- "asc": true,- "nulls": "last"- }- ],- "isUnique": false,- "concurrently": false,- "method": "btree",- "with": {}- },- "chats_created_at_idx": {- "name": "chats_created_at_idx",- "columns": [- {- "expression": "created_at",- "isExpression": false,- "asc": true,- "nulls": "last"- }- ],- "isUnique": false,- "concurrently": false,- "method": "btree",- "with": {}- }- },- "foreignKeys": {},- "compositePrimaryKeys": {},- "uniqueConstraints": {},- "policies": {},- "checkConstraints": {},- "isRLSEnabled": false- },- "public.messages": {- "name": "messages",- "schema": "",- "columns": {- "id": {- "name": "id",- "type": "varchar(191)",- "primaryKey": false,- "notNull": true,- "default": ""- },- "chat_id": {- "name": "chat_id",- "type": "varchar(191)",- "primaryKey": false,- "notNull": true,- "default": ""- },- "role": {- "name": "role",- "type": "message_role",- "typeSchema": "public",- "primaryKey": false,- "notNull": true,- "default": ""- },- "created_at": {- "name": "created_at",- "type": "timestamp",- "primaryKey": false,- "notNull": true,- "default": "now()"- }- },- "indexes": {- "messages_chat_id_idx": {- "name": "messages_chat_id_idx",- "columns": [- {- "expression": "chat_id",- "isExpression": false,- "asc": true,- "nulls": "last"- }- ],- "isUnique": false,- "concurrently": false,- "method": "btree",- "with": {}- },- "messages_created_at_idx": {- "name": "messages_created_at_idx",- "columns": [- {- "expression": "created_at",- "isExpression": false,- "asc": true,- "nulls": "last"- }- ],- "isUnique": false,- "concurrently": false,- "method": "btree",- "with": {}- }- },- "foreignKeys": {- "messages_chat_id_fkey": {- "name": "messages_chat_id_fkey",- "tableFrom": "messages",- "tableTo": "chats",- "columnsFrom": ["chat_id"],- "columnsTo": ["id"],- "onDelete": "cascade",- "onUpdate": "cascade"- }- },- "compositePrimaryKeys": {},- "uniqueConstraints": {},- "policies": {},- "checkConstraints": {},- "isRLSEnabled": false- },- "public.parts": {- "name": "parts",- "schema": "",- "columns": {- "id": {- "name": "id",- "type": "varchar(191)",- "primaryKey": false,- "notNull": true,- "default": ""- },- "message_id": {- "name": "message_id",- "type": "varchar(191)",- "primaryKey": false,- "notNull": true,- "default": ""- },- "type": {- "name": "type",- "type": "varchar(256)",- "primaryKey": false,- "notNull": true,- "default": ""- },- "order": {- "name": "order",- "type": "integer",- "primaryKey": false,- "notNull": true,- "default": ""- },- "text": {- "name": "text",- "type": "text",- "primaryKey": false,- "notNull": false,- "default": ""- },- "reasoning_text": {- "name": "reasoning_text",- "type": "text",- "primaryKey": false,- "notNull": false,- "default": ""- },- "file_media_type": {- "name": "file_media_type",- "type": "varchar(256)",- "primaryKey": false,- "notNull": false,- "default": ""- },- "file_filename": {- "name": "file_filename",- "type": "varchar(256)",- "primaryKey": false,- "notNull": false,- "default": ""- },- "file_url": {- "name": "file_url",- "type": "text",- "primaryKey": false,- "notNull": false,- "default": ""- },- "source_url_source_id": {- "name": "source_url_source_id",- "type": "varchar(256)",- "primaryKey": false,- "notNull": false,- "default": ""- },- "source_url_url": {- "name": "source_url_url",- "type": "text",- "primaryKey": false,- "notNull": false,- "default": ""- },- "source_url_title": {- "name": "source_url_title",- "type": "text",- "primaryKey": false,- "notNull": false,- "default": ""- },- "source_document_source_id": {- "name": "source_document_source_id",- "type": "varchar(256)",- "primaryKey": false,- "notNull": false,- "default": ""- },- "source_document_media_type": {- "name": "source_document_media_type",- "type": "varchar(256)",- "primaryKey": false,- "notNull": false,- "default": ""- },- "source_document_title": {- "name": "source_document_title",- "type": "text",- "primaryKey": false,- "notNull": false,- "default": ""- },- "source_document_filename": {- "name": "source_document_filename",- "type": "varchar(256)",- "primaryKey": false,- "notNull": false,- "default": ""- },- "source_document_url": {- "name": "source_document_url",- "type": "text",- "primaryKey": false,- "notNull": false,- "default": ""- },- "source_document_snippet": {- "name": "source_document_snippet",- "type": "text",- "primaryKey": false,- "notNull": false,- "default": ""- },- "tool_call_id": {- "name": "tool_call_id",- "type": "varchar(256)",- "primaryKey": false,- "notNull": false,- "default": ""- },- "tool_name": {- "name": "tool_name",- "type": "varchar(256)",- "primaryKey": false,- "notNull": false,- "default": ""- },- "tool_args": {- "name": "tool_args",- "type": "json",- "primaryKey": false,- "notNull": false,- "default": ""- },- "result": {- "name": "result",- "type": "json",- "primaryKey": false,- "notNull": false,- "default": ""- },- "is_error": {- "name": "is_error",- "type": "boolean",- "primaryKey": false,- "notNull": false,- "default": false- },- "tool_tool_call_id": {- "name": "tool_tool_call_id",- "type": "varchar(256)",- "primaryKey": false,- "notNull": false,- "default": ""- },- "tool_state": {- "name": "tool_state",- "type": "tool_state",- "typeSchema": "public",- "primaryKey": false,- "notNull": false,- "default": ""- },- "tool_error_text": {- "name": "tool_error_text",- "type": "text",- "primaryKey": false,- "notNull": false,- "default": ""- },- "tool_search_input": {- "name": "tool_search_input",- "type": "json",- "primaryKey": false,- "notNull": false,- "default": ""- },- "tool_search_output": {- "name": "tool_search_output",- "type": "json",- "primaryKey": false,- "notNull": false,- "default": ""- },- "tool_retrieve_input": {- "name": "tool_retrieve_input",- "type": "json",- "primaryKey": false,- "notNull": false,- "default": ""- },- "tool_retrieve_output": {- "name": "tool_retrieve_output",- "type": "json",- "primaryKey": false,- "notNull": false,- "default": ""- },- "tool_question_input": {- "name": "tool_question_input",- "type": "json",- "primaryKey": false,- "notNull": false,- "default": ""- },- "tool_question_output": {- "name": "tool_question_output",- "type": "json",- "primaryKey": false,- "notNull": false,- "default": ""- },- "tool_video_search_input": {- "name": "tool_video_search_input",- "type": "json",- "primaryKey": false,- "notNull": false,- "default": ""- },- "tool_video_search_output": {- "name": "tool_video_search_output",- "type": "json",- "primaryKey": false,- "notNull": false,- "default": ""- },- "tool_related_questions_input": {- "name": "tool_related_questions_input",- "type": "json",- "primaryKey": false,- "notNull": false,- "default": ""- },- "tool_related_questions_output": {- "name": "tool_related_questions_output",- "type": "json",- "primaryKey": false,- "notNull": false,- "default": ""- },- "tool_mcp_input": {- "name": "tool_mcp_input",- "type": "json",- "primaryKey": false,- "notNull": false,- "default": ""- },- "tool_mcp_output": {- "name": "tool_mcp_output",- "type": "json",- "primaryKey": false,- "notNull": false,- "default": ""- },- "data_prefix": {- "name": "data_prefix",- "type": "varchar(256)",- "primaryKey": false,- "notNull": false,- "default": ""- },- "data_content": {- "name": "data_content",- "type": "json",- "primaryKey": false,- "notNull": false,- "default": ""- },- "data_id": {- "name": "data_id",- "type": "varchar(256)",- "primaryKey": false,- "notNull": false,- "default": ""- },- "created_at": {- "name": "created_at",- "type": "timestamp",- "primaryKey": false,- "notNull": true,- "default": "now()"- }- },- "indexes": {- "parts_message_id_idx": {- "name": "parts_message_id_idx",- "columns": [- {- "expression": "message_id",- "isExpression": false,- "asc": true,- "nulls": "last"- }- ],- "isUnique": false,- "concurrently": false,- "method": "btree",- "with": {}- }- },- "foreignKeys": {- "parts_message_id_fkey": {- "name": "parts_message_id_fkey",- "tableFrom": "parts",- "tableTo": "messages",- "columnsFrom": ["message_id"],- "columnsTo": ["id"],- "onDelete": "cascade",- "onUpdate": "cascade"- }- },- "compositePrimaryKeys": {},- "uniqueConstraints": {},- "policies": {},- "checkConstraints": {},- "isRLSEnabled": false- }- },- "enums": {- "public.message_role": {- "name": "message_role",- "schema": "public",- "values": ["user", "assistant", "system", "data"]- },- "public.tool_state": {- "name": "tool_state",- "schema": "public",- "values": [- "input-streaming",- "input-available",- "output-available",- "output-error"- ]- },- "public.visibility_type": {- "name": "visibility_type",- "schema": "public",- "values": ["public", "private"]- }- },- "schemas": {},- "_meta": {- "columns": {},- "schemas": {},- "tables": {}- }-}diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.jsonindex 7ac7826f..8d87dbed 100644--- a/drizzle/meta/_journal.json+++ b/drizzle/meta/_journal.json@@ -5,23 +5,9 @@{"idx": 0,"version": "7",- "when": 1747030742056,- "tag": "0000_melodic_unicorn",- "breakpoints": true- },- {- "idx": 1,- "version": "7",- "when": 1753524626533,- "tag": "0001_busy_katie_power",- "breakpoints": true- },- {- "idx": 2,- "version": "7",- "when": 1753525000000,- "tag": "0002_add_related_questions_columns",+ "when": 1753666852574,+ "tag": "0000_perfect_ares","breakpoints": true}]-}+}\ No newline at end of filediff --git a/drizzle/migrations/0000_famous_gunslinger.sql b/drizzle/migrations/0000_famous_gunslinger.sqldeleted file mode 100644index 245faaad..00000000--- a/drizzle/migrations/0000_famous_gunslinger.sql+++ /dev/null@@ -1,19 +0,0 @@-CREATE TABLE "chats" (- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,- "created_at" timestamp with time zone DEFAULT now() NOT NULL,- "updated_at" timestamp with time zone DEFAULT now() NOT NULL,- "title" text NOT NULL,- "user_id" uuid NOT NULL,- "visibility" varchar(256) DEFAULT 'private' NOT NULL-);---> statement-breakpoint-CREATE TABLE "messages" (- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,- "chat_id" uuid NOT NULL,- "role" varchar(256) NOT NULL,- "parts" json NOT NULL,- "created_at" timestamp with time zone DEFAULT now() NOT NULL,- "updated_at" timestamp with time zone DEFAULT now() NOT NULL-);---> statement-breakpoint-ALTER TABLE "messages" ADD CONSTRAINT "messages_chat_id_chats_id_fk" FOREIGN KEY ("chat_id") REFERENCES "public"."chats"("id") ON DELETE cascade ON UPDATE no action;\ No newline at end of filediff --git a/drizzle/migrations/0001_update_schema_drop_updated_at.sql b/drizzle/migrations/0001_update_schema_drop_updated_at.sqldeleted file mode 100644index e231d4ae..00000000--- a/drizzle/migrations/0001_update_schema_drop_updated_at.sql+++ /dev/null@@ -1,8 +0,0 @@--- Drop updatedAt column from chats table-ALTER TABLE "chats" DROP COLUMN "updated_at";---- Drop updatedAt column from messages table-ALTER TABLE "messages" DROP COLUMN "updated_at";---- Add attachments column to messages table-ALTER TABLE "messages" ADD COLUMN "attachments" jsonb NOT NULL DEFAULT '{}';\ No newline at end of filediff --git a/drizzle/migrations/0002_enable_rls.sql b/drizzle/migrations/0002_enable_rls.sqldeleted file mode 100644index 64cf4f61..00000000--- a/drizzle/migrations/0002_enable_rls.sql+++ /dev/null@@ -1,87 +0,0 @@--- Enable RLS on tables-ALTER TABLE "chats" ENABLE ROW LEVEL SECURITY;-ALTER TABLE "messages" ENABLE ROW LEVEL SECURITY;---- Create policies for chats table-CREATE POLICY "Users can view their own chats" ON "chats"-FOR SELECT-TO authenticated-USING ((auth.uid())::uuid = "user_id");--CREATE POLICY "Users can view public chats" ON "chats"-FOR SELECT-TO authenticated, anon-USING ("visibility" = 'public');--CREATE POLICY "Users can insert their own chats" ON "chats"-FOR INSERT-TO authenticated-WITH CHECK ((auth.uid())::uuid = "user_id");--CREATE POLICY "Users can update their own chats" ON "chats"-FOR UPDATE-TO authenticated-USING ((auth.uid())::uuid = "user_id")-WITH CHECK ((auth.uid())::uuid = "user_id");--CREATE POLICY "Users can delete their own chats" ON "chats"-FOR DELETE-TO authenticated-USING ((auth.uid())::uuid = "user_id");---- Create policies for messages table-CREATE POLICY "Users can view messages from their own chats" ON "messages"-FOR SELECT-TO authenticated-USING (- "chat_id" IN (- SELECT "id" FROM "chats"- WHERE (auth.uid())::uuid = "user_id"- )-);--CREATE POLICY "Users can view messages from public chats" ON "messages"-FOR SELECT-TO authenticated, anon-USING (- "chat_id" IN (- SELECT "id" FROM "chats"- WHERE "visibility" = 'public'- )-);--CREATE POLICY "Users can insert messages to their own chats" ON "messages"-FOR INSERT-TO authenticated-WITH CHECK (- "chat_id" IN (- SELECT "id" FROM "chats"- WHERE (auth.uid())::uuid = "user_id"- )-);--CREATE POLICY "Users can update messages in their own chats" ON "messages"-FOR UPDATE-TO authenticated-USING (- "chat_id" IN (- SELECT "id" FROM "chats"- WHERE (auth.uid())::uuid = "user_id"- )-)-WITH CHECK (- "chat_id" IN (- SELECT "id" FROM "chats"- WHERE (auth.uid())::uuid = "user_id"- )-);--CREATE POLICY "Users can delete messages from their own chats" ON "messages"-FOR DELETE-TO authenticated-USING (- "chat_id" IN (- SELECT "id" FROM "chats"- WHERE (auth.uid())::uuid = "user_id"- )-);\ No newline at end of filediff --git a/drizzle/migrations/meta/0000_snapshot.json b/drizzle/migrations/meta/0000_snapshot.jsondeleted file mode 100644index 93637771..00000000--- a/drizzle/migrations/meta/0000_snapshot.json+++ /dev/null@@ -1,134 +0,0 @@-{- "id": "baef7eb3-6b14-444a-82ce-0d1a060c98ad",- "prevId": "00000000-0000-0000-0000-000000000000",- "version": "7",- "dialect": "postgresql",- "tables": {- "public.chats": {- "name": "chats",- "schema": "",- "columns": {- "id": {- "name": "id",- "type": "uuid",- "primaryKey": true,- "notNull": true,- "default": "gen_random_uuid()"- },- "created_at": {- "name": "created_at",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": true,- "default": "now()"- },- "updated_at": {- "name": "updated_at",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": true,- "default": "now()"- },- "title": {- "name": "title",- "type": "text",- "primaryKey": false,- "notNull": true- },- "user_id": {- "name": "user_id",- "type": "uuid",- "primaryKey": false,- "notNull": true- },- "visibility": {- "name": "visibility",- "type": "varchar(256)",- "primaryKey": false,- "notNull": true,- "default": "'private'"- }- },- "indexes": {},- "foreignKeys": {},- "compositePrimaryKeys": {},- "uniqueConstraints": {},- "policies": {},- "checkConstraints": {},- "isRLSEnabled": false- },- "public.messages": {- "name": "messages",- "schema": "",- "columns": {- "id": {- "name": "id",- "type": "uuid",- "primaryKey": true,- "notNull": true,- "default": "gen_random_uuid()"- },- "chat_id": {- "name": "chat_id",- "type": "uuid",- "primaryKey": false,- "notNull": true- },- "role": {- "name": "role",- "type": "varchar(256)",- "primaryKey": false,- "notNull": true- },- "parts": {- "name": "parts",- "type": "json",- "primaryKey": false,- "notNull": true- },- "created_at": {- "name": "created_at",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": true,- "default": "now()"- },- "updated_at": {- "name": "updated_at",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": true,- "default": "now()"- }- },- "indexes": {},- "foreignKeys": {- "messages_chat_id_chats_id_fk": {- "name": "messages_chat_id_chats_id_fk",- "tableFrom": "messages",- "tableTo": "chats",- "columnsFrom": ["chat_id"],- "columnsTo": ["id"],- "onDelete": "cascade",- "onUpdate": "no action"- }- },- "compositePrimaryKeys": {},- "uniqueConstraints": {},- "policies": {},- "checkConstraints": {},- "isRLSEnabled": false- }- },- "enums": {},- "schemas": {},- "sequences": {},- "roles": {},- "policies": {},- "views": {},- "_meta": {- "columns": {},- "schemas": {},- "tables": {}- }-}diff --git a/drizzle/migrations/meta/0001_snapshot.json b/drizzle/migrations/meta/0001_snapshot.jsondeleted file mode 100644index c001db6a..00000000--- a/drizzle/migrations/meta/0001_snapshot.json+++ /dev/null@@ -1,127 +0,0 @@-{- "id": "74bfe8c4-6a83-4e8a-9d1c-2b5a7f31e0f4",- "prevId": "baef7eb3-6b14-444a-82ce-0d1a060c98ad",- "version": "7",- "dialect": "postgresql",- "tables": {- "public.chats": {- "name": "chats",- "schema": "",- "columns": {- "id": {- "name": "id",- "type": "uuid",- "primaryKey": true,- "notNull": true,- "default": "gen_random_uuid()"- },- "created_at": {- "name": "created_at",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": true,- "default": "now()"- },- "title": {- "name": "title",- "type": "text",- "primaryKey": false,- "notNull": true- },- "user_id": {- "name": "user_id",- "type": "uuid",- "primaryKey": false,- "notNull": true- },- "visibility": {- "name": "visibility",- "type": "varchar(256)",- "primaryKey": false,- "notNull": true,- "default": "'private'"- }- },- "indexes": {},- "foreignKeys": {},- "compositePrimaryKeys": {},- "uniqueConstraints": {},- "policies": {},- "checkConstraints": {},- "isRLSEnabled": false- },- "public.messages": {- "name": "messages",- "schema": "",- "columns": {- "id": {- "name": "id",- "type": "uuid",- "primaryKey": true,- "notNull": true,- "default": "gen_random_uuid()"- },- "chat_id": {- "name": "chat_id",- "type": "uuid",- "primaryKey": false,- "notNull": true- },- "role": {- "name": "role",- "type": "varchar(256)",- "primaryKey": false,- "notNull": true- },- "parts": {- "name": "parts",- "type": "json",- "primaryKey": false,- "notNull": true- },- "attachments": {- "name": "attachments",- "type": "json",- "primaryKey": false,- "notNull": true,- "default": "'{}'::jsonb"- },- "created_at": {- "name": "created_at",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": true,- "default": "now()"- }- },- "indexes": {},- "foreignKeys": {- "messages_chat_id_chats_id_fk": {- "name": "messages_chat_id_chats_id_fk",- "tableFrom": "messages",- "tableTo": "chats",- "columnsFrom": ["chat_id"],- "columnsTo": ["id"],- "onDelete": "cascade",- "onUpdate": "no action"- }- },- "compositePrimaryKeys": {},- "uniqueConstraints": {},- "policies": {},- "checkConstraints": {},- "isRLSEnabled": false- }- },- "enums": {},- "schemas": {},- "sequences": {},- "roles": {},- "policies": {},- "views": {},- "_meta": {- "columns": {},- "schemas": {},- "tables": {}- }-}diff --git a/drizzle/migrations/meta/0002_snapshot.json b/drizzle/migrations/meta/0002_snapshot.jsondeleted file mode 100644index e6a3bad4..00000000--- a/drizzle/migrations/meta/0002_snapshot.json+++ /dev/null@@ -1,189 +0,0 @@-{- "id": "fb8e1dca-4a37-41e5-b928-c32e86e9f5b6",- "prevId": "74bfe8c4-6a83-4e8a-9d1c-2b5a7f31e0f4",- "version": "7",- "dialect": "postgresql",- "tables": {- "public.chats": {- "name": "chats",- "schema": "",- "columns": {- "id": {- "name": "id",- "type": "uuid",- "primaryKey": true,- "notNull": true,- "default": "gen_random_uuid()"- },- "created_at": {- "name": "created_at",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": true,- "default": "now()"- },- "title": {- "name": "title",- "type": "text",- "primaryKey": false,- "notNull": true- },- "user_id": {- "name": "user_id",- "type": "uuid",- "primaryKey": false,- "notNull": true- },- "visibility": {- "name": "visibility",- "type": "varchar(256)",- "primaryKey": false,- "notNull": true,- "default": "'private'"- }- },- "indexes": {},- "foreignKeys": {},- "compositePrimaryKeys": {},- "uniqueConstraints": {},- "policies": {- "Users can view their own chats": {- "using": "(auth.uid()::uuid = user_id)",- "check": null,- "operation": "select",- "roles": ["authenticated"]- },- "Users can view public chats": {- "using": "(visibility = 'public')",- "check": null,- "operation": "select",- "roles": ["authenticated", "anon"]- },- "Users can insert their own chats": {- "using": null,- "check": "(auth.uid()::uuid = user_id)",- "operation": "insert",- "roles": ["authenticated"]- },- "Users can update their own chats": {- "using": "(auth.uid()::uuid = user_id)",- "check": "(auth.uid()::uuid = user_id)",- "operation": "update",- "roles": ["authenticated"]- },- "Users can delete their own chats": {- "using": "(auth.uid()::uuid = user_id)",- "check": null,- "operation": "delete",- "roles": ["authenticated"]- }- },- "checkConstraints": {},- "isRLSEnabled": true- },- "public.messages": {- "name": "messages",- "schema": "",- "columns": {- "id": {- "name": "id",- "type": "uuid",- "primaryKey": true,- "notNull": true,- "default": "gen_random_uuid()"- },- "chat_id": {- "name": "chat_id",- "type": "uuid",- "primaryKey": false,- "notNull": true- },- "role": {- "name": "role",- "type": "varchar(256)",- "primaryKey": false,- "notNull": true- },- "parts": {- "name": "parts",- "type": "json",- "primaryKey": false,- "notNull": true- },- "attachments": {- "name": "attachments",- "type": "json",- "primaryKey": false,- "notNull": true,- "default": "'{}'::jsonb"- },- "created_at": {- "name": "created_at",- "type": "timestamp with time zone",- "primaryKey": false,- "notNull": true,- "default": "now()"- }- },- "indexes": {},- "foreignKeys": {- "messages_chat_id_chats_id_fk": {- "name": "messages_chat_id_chats_id_fk",- "tableFrom": "messages",- "tableTo": "chats",- "columnsFrom": ["chat_id"],- "columnsTo": ["id"],- "onDelete": "cascade",- "onUpdate": "no action"- }- },- "compositePrimaryKeys": {},- "uniqueConstraints": {},- "policies": {- "Users can view messages from their own chats": {- "using": "(chat_id IN (SELECT id FROM chats WHERE (auth.uid())::uuid = user_id))",- "check": null,- "operation": "select",- "roles": ["authenticated"]- },- "Users can view messages from public chats": {- "using": "(chat_id IN (SELECT id FROM chats WHERE visibility = 'public'))",- "check": null,- "operation": "select",- "roles": ["authenticated", "anon"]- },- "Users can insert messages to their own chats": {- "using": null,- "check": "(chat_id IN (SELECT id FROM chats WHERE (auth.uid())::uuid = user_id))",- "operation": "insert",- "roles": ["authenticated"]- },- "Users can update messages in their own chats": {- "using": "(chat_id IN (SELECT id FROM chats WHERE (auth.uid())::uuid = user_id))",- "check": "(chat_id IN (SELECT id FROM chats WHERE (auth.uid())::uuid = user_id))",- "operation": "update",- "roles": ["authenticated"]- },- "Users can delete messages from their own chats": {- "using": "(chat_id IN (SELECT id FROM chats WHERE (auth.uid())::uuid = user_id))",- "check": null,- "operation": "delete",- "roles": ["authenticated"]- }- },- "checkConstraints": {},- "isRLSEnabled": true- }- },- "enums": {},- "schemas": {},- "sequences": {},- "roles": {},- "policies": {},- "views": {},- "_meta": {- "columns": {},- "schemas": {},- "tables": {}- }-}diff --git a/drizzle/migrations/meta/_journal.json b/drizzle/migrations/meta/_journal.jsondeleted file mode 100644index 2d9836ec..00000000--- a/drizzle/migrations/meta/_journal.json+++ /dev/null@@ -1,27 +0,0 @@-{- "version": "7",- "dialect": "postgresql",- "entries": [- {- "idx": 0,- "version": "7",- "when": 1747030516658,- "tag": "0000_famous_gunslinger",- "breakpoints": true- },- {- "idx": 1,- "version": "7",- "when": 1747030781234,- "tag": "0001_update_schema_drop_updated_at",- "breakpoints": true- },- {- "idx": 2,- "version": "7",- "when": 1747032500000,- "tag": "0002_enable_rls",- "breakpoints": true- }- ]-}diff --git a/lib/db/migrate.ts b/lib/db/migrate.tsindex b6e89b98..dceda0bc 100644--- a/lib/db/migrate.ts+++ b/lib/db/migrate.ts@@ -26,7 +26,7 @@ const runMigrations = async () => {console.log('Running migrations...')try {- await migrate(db, { migrationsFolder: 'drizzle/migrations' })+ await migrate(db, { migrationsFolder: 'drizzle' })console.log('Migrations completed successfully')} catch (error) {console.error('Migration failed:', error)