CREATE INDEX IF NOT EXISTS "agents_files_file_id_idx" ON "agents_files" USING btree ("file_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "agents_files_user_id_idx" ON "agents_files" USING btree ("user_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "agents_knowledge_bases_knowledge_base_id_idx" ON "agents_knowledge_bases" USING btree ("knowledge_base_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "agents_knowledge_bases_user_id_idx" ON "agents_knowledge_bases" USING btree ("user_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "chat_groups_user_id_idx" ON "chat_groups" USING btree ("user_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "chat_groups_agents_user_id_idx" ON "chat_groups_agents" USING btree ("user_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "files_chunk_task_id_idx" ON "files" USING btree ("chunk_task_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "files_embedding_task_id_idx" ON "files" USING btree ("embedding_task_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "knowledge_base_files_user_id_idx" ON "knowledge_base_files" USING btree ("user_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "knowledge_base_files_file_id_idx" ON "knowledge_base_files" USING btree ("file_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "generations_file_id_idx" ON "generations" USING btree ("file_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "message_chunks_user_id_idx" ON "message_chunks" USING btree ("user_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "message_chunks_message_id_idx" ON "message_chunks" USING btree ("message_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "message_groups_user_id_idx" ON "message_groups" USING btree ("user_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "message_groups_parent_group_id_idx" ON "message_groups" USING btree ("parent_group_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "message_groups_parent_message_id_idx" ON "message_groups" USING btree ("parent_message_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "message_plugins_user_id_idx" ON "message_plugins" USING btree ("user_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "message_queries_user_id_idx" ON "message_queries" USING btree ("user_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "message_queries_message_id_idx" ON "message_queries" USING btree ("message_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "message_queries_embeddings_id_idx" ON "message_queries" USING btree ("embeddings_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "message_query_chunks_user_id_idx" ON "message_query_chunks" USING btree ("user_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "message_query_chunks_message_id_idx" ON "message_query_chunks" USING btree ("id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "message_query_chunks_query_id_idx" ON "message_query_chunks" USING btree ("query_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "message_tts_user_id_idx" ON "message_tts" USING btree ("user_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "message_translates_user_id_idx" ON "message_translates" USING btree ("user_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "messages_files_user_id_idx" ON "messages_files" USING btree ("user_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "messages_files_message_id_idx" ON "messages_files" USING btree ("message_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "nextauth_accounts_user_id_idx" ON "nextauth_accounts" USING btree ("user_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "nextauth_sessions_user_id_idx" ON "nextauth_sessions" USING btree ("user_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "oidc_access_tokens_user_id_idx" ON "oidc_access_tokens" USING btree ("user_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "oidc_authorization_codes_user_id_idx" ON "oidc_authorization_codes" USING btree ("user_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "oidc_device_codes_user_id_idx" ON "oidc_device_codes" USING btree ("user_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "oidc_grants_user_id_idx" ON "oidc_grants" USING btree ("user_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "oidc_refresh_tokens_user_id_idx" ON "oidc_refresh_tokens" USING btree ("user_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "oidc_sessions_user_id_idx" ON "oidc_sessions" USING btree ("user_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "document_chunks_user_id_idx" ON "document_chunks" USING btree ("user_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "unstructured_chunks_user_id_idx" ON "unstructured_chunks" USING btree ("user_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "unstructured_chunks_composite_id_idx" ON "unstructured_chunks" USING btree ("composite_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "unstructured_chunks_file_id_idx" ON "unstructured_chunks" USING btree ("file_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "rag_eval_dataset_records_user_id_idx" ON "rag_eval_dataset_records" USING btree ("user_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "rag_eval_datasets_user_id_idx" ON "rag_eval_datasets" USING btree ("user_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "rag_eval_evaluations_user_id_idx" ON "rag_eval_evaluations" USING btree ("user_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "rag_eval_evaluation_records_user_id_idx" ON "rag_eval_evaluation_records" USING btree ("user_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "agents_to_sessions_user_id_idx" ON "agents_to_sessions" USING btree ("user_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "file_chunks_user_id_idx" ON "file_chunks" USING btree ("user_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "file_chunks_file_id_idx" ON "file_chunks" USING btree ("file_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "file_chunks_chunk_id_idx" ON "file_chunks" USING btree ("chunk_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "files_to_sessions_user_id_idx" ON "files_to_sessions" USING btree ("user_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "files_to_sessions_file_id_idx" ON "files_to_sessions" USING btree ("file_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "files_to_sessions_session_id_idx" ON "files_to_sessions" USING btree ("session_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "session_groups_user_id_idx" ON "session_groups" USING btree ("user_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "threads_user_id_idx" ON "threads" USING btree ("user_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "threads_parent_thread_id_idx" ON "threads" USING btree ("parent_thread_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "topic_documents_user_id_idx" ON "topic_documents" USING btree ("user_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "topic_documents_topic_id_idx" ON "topic_documents" USING btree ("topic_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "topic_documents_document_id_idx" ON "topic_documents" USING btree ("document_id");