An AI-powered search engine with a generative UI
TypeScript generative-aigenerative-uinextjsollamareactsearxngshadcn-uitailwindcsstavilytypescriptupstashvercel-ai-sdk
Fix Drizzle migration system and sync with lib/db/migrations
Yoshiki Miura22abefc8dd6d
diff --git a/drizzle.config.ts b/drizzle.config.tsindex 347df91c..96f31675 100644--- a/drizzle.config.ts+++ b/drizzle.config.ts@@ -1,5 +1,11 @@import 'dotenv/config'import { defineConfig } from 'drizzle-kit'+import * as dotenv from 'dotenv'++// Load from .env.local if DATABASE_URL is not set+if (!process.env.DATABASE_URL) {+ dotenv.config({ path: '.env.local' })+}export default defineConfig({schema: './lib/db/schema.ts',diff --git a/drizzle/0000_perfect_ares.sql b/drizzle/0000_perfect_ares.sqldeleted file mode 100644index fac79927..00000000--- a/drizzle/0000_perfect_ares.sql+++ /dev/null@@ -1,67 +0,0 @@-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-breakpoint-CREATE TABLE "parts" (- "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,- "reasoning_text" text,- "file_media_type" varchar(256),- "file_filename" varchar(1024),- "file_url" text,- "source_url_source_id" varchar(256),- "source_url_url" text,- "source_url_title" text,- "source_document_source_id" varchar(256),- "source_document_media_type" varchar(256),- "source_document_title" text,- "source_document_filename" varchar(1024),- "source_document_url" text,- "source_document_snippet" text,- "tool_tool_call_id" varchar(256),- "tool_state" varchar(256),- "tool_error_text" text,- "tool_search_input" json,- "tool_search_output" json,- "tool_retrieve_input" json,- "tool_retrieve_output" json,- "tool_question_input" json,- "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 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))),- CONSTRAINT "tool_state_valid" CHECK ((tool_state IS NULL OR tool_state IN ('input-streaming', 'input-available', 'output-available', 'output-error'))),- 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 "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-breakpoint-ALTER 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 "messages_chat_id_idx" ON "messages" USING btree ("chat_id");--> statement-breakpoint-CREATE INDEX "messages_chat_id_created_at_idx" ON "messages" USING btree ("chat_id","created_at");--> 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");\ No newline at end of filediff --git a/drizzle/0001_persistence_v5.sql b/drizzle/0001_persistence_v5.sqlnew file mode 100644index 00000000..515c13d4--- /dev/null+++ b/drizzle/0001_persistence_v5.sql@@ -0,0 +1,108 @@+-- Drop existing tables if they exist (clean slate approach)+DROP TABLE IF EXISTS messages CASCADE;+DROP TABLE IF EXISTS chats CASCADE;++-- Create new chats table with generateId+CREATE TABLE chats (+ id VARCHAR PRIMARY KEY,+ created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL,+ title TEXT NOT NULL,+ user_id VARCHAR NOT NULL,+ visibility VARCHAR(256) DEFAULT 'private' NOT NULL CHECK (visibility IN ('public', 'private'))+);++-- Create new messages table (simplified)+CREATE TABLE messages (+ id VARCHAR PRIMARY KEY,+ chat_id VARCHAR NOT NULL REFERENCES chats(id) ON DELETE CASCADE,+ role VARCHAR(256) NOT NULL,+ created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL+);++-- Create indexes for messages+CREATE INDEX messages_chat_id_idx ON messages(chat_id);+CREATE INDEX messages_chat_id_created_at_idx ON messages(chat_id, created_at);++-- Create parts table+CREATE TABLE parts (+ id VARCHAR PRIMARY KEY,+ message_id VARCHAR NOT NULL REFERENCES messages(id) ON DELETE CASCADE,+ "order" INTEGER NOT NULL,+ type VARCHAR(256) NOT NULL,++ -- Text parts+ text_text TEXT,++ -- Reasoning parts+ reasoning_text TEXT,++ -- File parts+ file_media_type VARCHAR(256),+ file_filename VARCHAR(1024),+ file_url TEXT,++ -- Source URL parts+ source_url_source_id VARCHAR(256),+ source_url_url TEXT,+ source_url_title TEXT,++ -- Source document parts+ source_document_source_id VARCHAR(256),+ source_document_media_type VARCHAR(256),+ source_document_title TEXT,+ source_document_filename VARCHAR(1024),+ source_document_url TEXT,+ source_document_snippet TEXT,++ -- Tool parts (generic)+ tool_tool_call_id VARCHAR(256),+ tool_state VARCHAR(256),+ tool_error_text TEXT,++ -- Tool-specific columns+ tool_search_input JSONB,+ tool_search_output JSONB,+ tool_retrieve_input JSONB,+ tool_retrieve_output JSONB,+ tool_question_input JSONB,+ tool_question_output JSONB,+ tool_video_search_input JSONB,+ tool_video_search_output JSONB,+ tool_mcp_input JSONB,+ tool_mcp_output JSONB,++ -- Data parts+ data_prefix VARCHAR(256),+ data_content JSONB,+ data_id VARCHAR(256),++ -- Provider metadata+ provider_metadata JSONB,++ created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL+);++-- Create indexes for parts+CREATE INDEX parts_message_id_idx ON parts(message_id);+CREATE INDEX parts_message_id_order_idx ON parts(message_id, "order");++-- Add constraints+ALTER TABLE parts ADD CONSTRAINT text_text_required+ CHECK (type != 'text' OR text_text IS NOT NULL);++ALTER TABLE parts ADD CONSTRAINT reasoning_text_required+ CHECK (type != 'reasoning' OR reasoning_text IS NOT NULL);++ALTER TABLE parts ADD 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));++ALTER TABLE parts ADD CONSTRAINT tool_state_valid+ CHECK (tool_state IS NULL OR tool_state IN ('input-streaming', 'input-available', 'output-available', 'output-error'));++ALTER TABLE parts ADD CONSTRAINT tool_fields_required+ CHECK (type NOT LIKE 'tool-%' OR (tool_tool_call_id IS NOT NULL AND tool_state IS NOT NULL));++-- Enable Row Level Security (if needed)+-- ALTER TABLE chats ENABLE ROW LEVEL SECURITY;+-- ALTER TABLE messages ENABLE ROW LEVEL SECURITY;+-- ALTER TABLE parts ENABLE ROW LEVEL SECURITY;\ No newline at end of filediff --git a/drizzle/0001_rename_mcp_to_dynamic.sql b/drizzle/0001_rename_mcp_to_dynamic.sqldeleted file mode 100644index f6f02cb0..00000000--- a/drizzle/0001_rename_mcp_to_dynamic.sql+++ /dev/null@@ -1,7 +0,0 @@--- Rename MCP columns to dynamic tool columns-ALTER TABLE "parts" RENAME COLUMN "tool_mcp_input" TO "tool_dynamic_input";-ALTER TABLE "parts" RENAME COLUMN "tool_mcp_output" TO "tool_dynamic_output";---- Add new columns for dynamic tool metadata-ALTER TABLE "parts" ADD COLUMN "tool_dynamic_name" varchar(256);-ALTER TABLE "parts" ADD COLUMN "tool_dynamic_type" varchar(256);\ No newline at end of filediff --git a/drizzle/0003_rename_mcp_to_dynamic.sql b/drizzle/0003_rename_mcp_to_dynamic.sqlnew file mode 100644index 00000000..1acb9851--- /dev/null+++ b/drizzle/0003_rename_mcp_to_dynamic.sql@@ -0,0 +1,11 @@+-- Rename MCP tool columns to dynamic tool columns+ALTER TABLE parts+ RENAME COLUMN tool_mcp_input TO tool_dynamic_input;++ALTER TABLE parts+ RENAME COLUMN tool_mcp_output TO tool_dynamic_output;++-- Add dynamic tool metadata columns for storing tool name and type+ALTER TABLE parts+ ADD COLUMN tool_dynamic_name VARCHAR(256),+ ADD COLUMN tool_dynamic_type VARCHAR(256);\ No newline at end of filediff --git a/drizzle/0004_rename_retrieve_to_fetch.sql b/drizzle/0004_rename_retrieve_to_fetch.sqlnew file mode 100644index 00000000..b41f99e5--- /dev/null+++ b/drizzle/0004_rename_retrieve_to_fetch.sql@@ -0,0 +1,11 @@+-- Migration: Rename retrieve tool columns to fetch+-- This migration renames the tool_retrieve_* columns to tool_fetch_*+-- to align with the renamed tool from 'retrieve' to 'fetch'++-- Rename tool_retrieve_input to tool_fetch_input+ALTER TABLE parts+RENAME COLUMN tool_retrieve_input TO tool_fetch_input;++-- Rename tool_retrieve_output to tool_fetch_output+ALTER TABLE parts+RENAME COLUMN tool_retrieve_output TO tool_fetch_output;\ No newline at end of filediff --git a/drizzle/0005_remove_video_search.sql b/drizzle/0005_remove_video_search.sqlnew file mode 100644index 00000000..ba080e76--- /dev/null+++ b/drizzle/0005_remove_video_search.sql@@ -0,0 +1,3 @@+-- Remove video search columns from parts table+ALTER TABLE "parts" DROP COLUMN IF EXISTS "tool_video_search_input";+ALTER TABLE "parts" DROP COLUMN IF EXISTS "tool_video_search_output";\ No newline at end of filediff --git a/drizzle/meta/0000_snapshot.json b/drizzle/meta/0001_snapshot.jsonsimilarity index 93%rename from drizzle/meta/0000_snapshot.jsonrename to drizzle/meta/0001_snapshot.jsonindex c847262b..c0c98cf0 100644--- a/drizzle/meta/0000_snapshot.json+++ b/drizzle/meta/0001_snapshot.json@@ -1,5 +1,5 @@{- "id": "c2116538-2854-48c0-b309-32cd2fb28e62",+ "id": "c17090d9-fd3a-47e3-8fff-c4cee21d0506","prevId": "00000000-0000-0000-0000-000000000000","version": "7","dialect": "postgresql",@@ -122,8 +122,12 @@"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"}@@ -276,14 +280,14 @@"primaryKey": false,"notNull": false},- "tool_retrieve_input": {- "name": "tool_retrieve_input",+ "tool_fetch_input": {+ "name": "tool_fetch_input","type": "json","primaryKey": false,"notNull": false},- "tool_retrieve_output": {- "name": "tool_retrieve_output",+ "tool_fetch_output": {+ "name": "tool_fetch_output","type": "json","primaryKey": false,"notNull": false@@ -300,39 +304,39 @@"primaryKey": false,"notNull": false},- "tool_video_search_input": {- "name": "tool_video_search_input",+ "tool_related_questions_input": {+ "name": "tool_related_questions_input","type": "json","primaryKey": false,"notNull": false},- "tool_video_search_output": {- "name": "tool_video_search_output",+ "tool_related_questions_output": {+ "name": "tool_related_questions_output","type": "json","primaryKey": false,"notNull": false},- "tool_related_questions_input": {- "name": "tool_related_questions_input",+ "tool_dynamic_input": {+ "name": "tool_dynamic_input","type": "json","primaryKey": false,"notNull": false},- "tool_related_questions_output": {- "name": "tool_related_questions_output",+ "tool_dynamic_output": {+ "name": "tool_dynamic_output","type": "json","primaryKey": false,"notNull": false},- "tool_mcp_input": {- "name": "tool_mcp_input",- "type": "json",+ "tool_dynamic_name": {+ "name": "tool_dynamic_name",+ "type": "varchar(256)","primaryKey": false,"notNull": false},- "tool_mcp_output": {- "name": "tool_mcp_output",- "type": "json",+ "tool_dynamic_type": {+ "name": "tool_dynamic_type",+ "type": "varchar(256)","primaryKey": false,"notNull": false},@@ -411,8 +415,12 @@"name": "parts_message_id_messages_id_fk","tableFrom": "parts","tableTo": "messages",- "columnsFrom": ["message_id"],- "columnsTo": ["id"],+ "columnsFrom": [+ "message_id"+ ],+ "columnsTo": [+ "id"+ ],"onDelete": "cascade","onUpdate": "no action"}@@ -456,4 +464,4 @@"schemas": {},"tables": {}}-}+}\ No newline at end of filediff --git a/drizzle/meta/0003_snapshot.json b/drizzle/meta/0003_snapshot.jsonnew file mode 100644index 00000000..c0c98cf0--- /dev/null+++ b/drizzle/meta/0003_snapshot.json@@ -0,0 +1,467 @@+{+ "id": "c17090d9-fd3a-47e3-8fff-c4cee21d0506",+ "prevId": "00000000-0000-0000-0000-000000000000",+ "version": "7",+ "dialect": "postgresql",+ "tables": {+ "public.chats": {+ "name": "chats",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(191)",+ "primaryKey": true,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "varchar(255)",+ "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(191)",+ "primaryKey": true,+ "notNull": true+ },+ "chat_id": {+ "name": "chat_id",+ "type": "varchar(191)",+ "primaryKey": false,+ "notNull": true+ },+ "role": {+ "name": "role",+ "type": "varchar(256)",+ "primaryKey": false,+ "notNull": true+ },+ "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_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(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_fetch_input": {+ "name": "tool_fetch_input",+ "type": "json",+ "primaryKey": false,+ "notNull": false+ },+ "tool_fetch_output": {+ "name": "tool_fetch_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_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_dynamic_input": {+ "name": "tool_dynamic_input",+ "type": "json",+ "primaryKey": false,+ "notNull": false+ },+ "tool_dynamic_output": {+ "name": "tool_dynamic_output",+ "type": "json",+ "primaryKey": false,+ "notNull": false+ },+ "tool_dynamic_name": {+ "name": "tool_dynamic_name",+ "type": "varchar(256)",+ "primaryKey": false,+ "notNull": false+ },+ "tool_dynamic_type": {+ "name": "tool_dynamic_type",+ "type": "varchar(256)",+ "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": {},+ "schemas": {},+ "sequences": {},+ "roles": {},+ "policies": {},+ "views": {},+ "_meta": {+ "columns": {},+ "schemas": {},+ "tables": {}+ }+}\ No newline at end of filediff --git a/drizzle/meta/0005_snapshot.json b/drizzle/meta/0005_snapshot.jsonnew file mode 100644index 00000000..c0c98cf0--- /dev/null+++ b/drizzle/meta/0005_snapshot.json@@ -0,0 +1,467 @@+{+ "id": "c17090d9-fd3a-47e3-8fff-c4cee21d0506",+ "prevId": "00000000-0000-0000-0000-000000000000",+ "version": "7",+ "dialect": "postgresql",+ "tables": {+ "public.chats": {+ "name": "chats",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(191)",+ "primaryKey": true,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "varchar(255)",+ "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(191)",+ "primaryKey": true,+ "notNull": true+ },+ "chat_id": {+ "name": "chat_id",+ "type": "varchar(191)",+ "primaryKey": false,+ "notNull": true+ },+ "role": {+ "name": "role",+ "type": "varchar(256)",+ "primaryKey": false,+ "notNull": true+ },+ "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_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(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_fetch_input": {+ "name": "tool_fetch_input",+ "type": "json",+ "primaryKey": false,+ "notNull": false+ },+ "tool_fetch_output": {+ "name": "tool_fetch_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_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_dynamic_input": {+ "name": "tool_dynamic_input",+ "type": "json",+ "primaryKey": false,+ "notNull": false+ },+ "tool_dynamic_output": {+ "name": "tool_dynamic_output",+ "type": "json",+ "primaryKey": false,+ "notNull": false+ },+ "tool_dynamic_name": {+ "name": "tool_dynamic_name",+ "type": "varchar(256)",+ "primaryKey": false,+ "notNull": false+ },+ "tool_dynamic_type": {+ "name": "tool_dynamic_type",+ "type": "varchar(256)",+ "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": {},+ "schemas": {},+ "sequences": {},+ "roles": {},+ "policies": {},+ "views": {},+ "_meta": {+ "columns": {},+ "schemas": {},+ "tables": {}+ }+}\ No newline at end of filediff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.jsonindex bcdf4713..6b623909 100644--- a/drizzle/meta/_journal.json+++ b/drizzle/meta/_journal.json@@ -5,16 +5,30 @@{"idx": 0,"version": "7",- "when": 1753666852574,- "tag": "0000_perfect_ares",+ "when": 1733333000000,+ "tag": "0001_persistence_v5","breakpoints": true},{"idx": 1,"version": "7",- "when": 1753666852575,- "tag": "0001_rename_mcp_to_dynamic",+ "when": 1733333001000,+ "tag": "0003_rename_mcp_to_dynamic",+ "breakpoints": true+ },+ {+ "idx": 2,+ "version": "7",+ "when": 1733333002000,+ "tag": "0004_rename_retrieve_to_fetch",+ "breakpoints": true+ },+ {+ "idx": 3,+ "version": "7",+ "when": 1733333003000,+ "tag": "0005_remove_video_search","breakpoints": true}]-}+}\ No newline at end of file