mirror of
https://github.com/run-llama/ai-chatbot.git
synced 2026-06-30 21:27:54 -04:00
Refactor drizzle and db folder
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
import { z } from 'zod';
|
||||
|
||||
import { createUser, getUser } from '@/db/queries';
|
||||
import { createUser, getUser } from '@/lib/db/queries';
|
||||
|
||||
import { signIn } from './auth';
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ import { compare } from 'bcrypt-ts';
|
||||
import NextAuth, { User, Session } from 'next-auth';
|
||||
import Credentials from 'next-auth/providers/credentials';
|
||||
|
||||
import { getUser } from '@/db/queries';
|
||||
import { getUser } from '@/lib/db/queries';
|
||||
|
||||
import { authConfig } from './auth.config';
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ import {
|
||||
saveDocument,
|
||||
saveMessages,
|
||||
saveSuggestions,
|
||||
} from '@/db/queries';
|
||||
import { Suggestion } from '@/db/schema';
|
||||
} from '@/lib/db/queries';
|
||||
import { Suggestion } from '@/lib/db/schema';
|
||||
import {
|
||||
generateUUID,
|
||||
getMostRecentUserMessage,
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
deleteDocumentsByIdAfterTimestamp,
|
||||
getDocumentsById,
|
||||
saveDocument,
|
||||
} from '@/db/queries';
|
||||
} from '@/lib/db/queries';
|
||||
|
||||
export async function GET(request: Request) {
|
||||
const { searchParams } = new URL(request.url);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { auth } from '@/app/(auth)/auth';
|
||||
import { getChatsByUserId } from '@/db/queries';
|
||||
import { getChatsByUserId } from '@/lib/db/queries';
|
||||
|
||||
export async function GET() {
|
||||
const session = await auth();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { auth } from '@/app/(auth)/auth';
|
||||
import { getSuggestionsByDocumentId } from '@/db/queries';
|
||||
import { getSuggestionsByDocumentId } from '@/lib/db/queries';
|
||||
|
||||
export async function GET(request: Request) {
|
||||
const { searchParams } = new URL(request.url);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { auth } from '@/app/(auth)/auth';
|
||||
import { getVotesByChatId, voteMessage } from '@/db/queries';
|
||||
import { getVotesByChatId, voteMessage } from '@/lib/db/queries';
|
||||
|
||||
export async function GET(request: Request) {
|
||||
const { searchParams } = new URL(request.url);
|
||||
|
||||
@@ -5,7 +5,7 @@ import { notFound } from 'next/navigation';
|
||||
import { DEFAULT_MODEL_NAME, models } from '@/ai/models';
|
||||
import { auth } from '@/app/(auth)/auth';
|
||||
import { Chat as PreviewChat } from '@/components/custom/chat';
|
||||
import { getChatById, getMessagesByChatId } from '@/db/queries';
|
||||
import { getChatById, getMessagesByChatId } from '@/lib/db/queries';
|
||||
import { convertToUIMessages } from '@/lib/utils';
|
||||
|
||||
export default async function Page(props: { params: Promise<any> }) {
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
useWindowSize,
|
||||
} from 'usehooks-ts';
|
||||
|
||||
import { Document, Suggestion, Vote } from '@/db/schema';
|
||||
import { Document, Suggestion, Vote } from '@/lib/db/schema';
|
||||
import { fetcher } from '@/lib/utils';
|
||||
|
||||
import { DiffView } from './diffview';
|
||||
|
||||
@@ -10,7 +10,7 @@ import { useWindowSize } from 'usehooks-ts';
|
||||
import { ChatHeader } from '@/components/custom/chat-header';
|
||||
import { PreviewMessage, ThinkingMessage } from '@/components/custom/message';
|
||||
import { useScrollToBottom } from '@/components/custom/use-scroll-to-bottom';
|
||||
import { Vote } from '@/db/schema';
|
||||
import { Vote } from '@/lib/db/schema';
|
||||
import { fetcher } from '@/lib/utils';
|
||||
|
||||
import { Block, UIBlock } from './block';
|
||||
|
||||
@@ -6,7 +6,7 @@ import { EditorState } from 'prosemirror-state';
|
||||
import { EditorView } from 'prosemirror-view';
|
||||
import React, { memo, useEffect, useRef } from 'react';
|
||||
|
||||
import { Suggestion } from '@/db/schema';
|
||||
import { Suggestion } from '@/lib/db/schema';
|
||||
import {
|
||||
documentSchema,
|
||||
handleTransaction,
|
||||
|
||||
@@ -3,7 +3,7 @@ import { toast } from 'sonner';
|
||||
import { useSWRConfig } from 'swr';
|
||||
import { useCopyToClipboard } from 'usehooks-ts';
|
||||
|
||||
import { Vote } from '@/db/schema';
|
||||
import { Vote } from '@/lib/db/schema';
|
||||
import { getMessageIdFromAnnotations } from '@/lib/utils';
|
||||
|
||||
import { CopyIcon, ThumbDownIcon, ThumbUpIcon } from './icons';
|
||||
|
||||
@@ -5,7 +5,7 @@ import cx from 'classnames';
|
||||
import { motion } from 'framer-motion';
|
||||
import { Dispatch, SetStateAction } from 'react';
|
||||
|
||||
import { Vote } from '@/db/schema';
|
||||
import { Vote } from '@/lib/db/schema';
|
||||
|
||||
import { UIBlock } from './block';
|
||||
import { DocumentToolCall, DocumentToolResult } from './document';
|
||||
|
||||
@@ -34,7 +34,7 @@ import {
|
||||
SidebarMenuItem,
|
||||
useSidebar,
|
||||
} from '@/components/ui/sidebar';
|
||||
import { Chat } from '@/db/schema';
|
||||
import { Chat } from '@/lib/db/schema';
|
||||
import { fetcher } from '@/lib/utils';
|
||||
|
||||
type GroupedChats = {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { JSONValue } from 'ai';
|
||||
import { Dispatch, SetStateAction, useEffect, useState } from 'react';
|
||||
import { useSWRConfig } from 'swr';
|
||||
|
||||
import { Suggestion } from '@/db/schema';
|
||||
import { Suggestion } from '@/lib/db/schema';
|
||||
|
||||
import { UIBlock } from './block';
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import { useState } from 'react';
|
||||
import { useSWRConfig } from 'swr';
|
||||
import { useWindowSize } from 'usehooks-ts';
|
||||
|
||||
import { Document } from '@/db/schema';
|
||||
import { Document } from '@/lib/db/schema';
|
||||
import { getDocumentTimestampByIndex } from '@/lib/utils';
|
||||
|
||||
import { UIBlock } from './block';
|
||||
|
||||
+2
-2
@@ -6,8 +6,8 @@ config({
|
||||
});
|
||||
|
||||
export default defineConfig({
|
||||
schema: './db/schema.ts',
|
||||
out: './lib/drizzle',
|
||||
schema: './lib/db/schema.ts',
|
||||
out: './lib/db/migrations',
|
||||
dialect: 'postgresql',
|
||||
dbCredentials: {
|
||||
url: process.env.POSTGRES_URL!,
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Decoration, DecorationSet, EditorView } from 'prosemirror-view';
|
||||
import { createRoot } from 'react-dom/client';
|
||||
|
||||
import { Suggestion as PreviewSuggestion } from '@/components/custom/suggestion';
|
||||
import { Suggestion } from '@/db/schema';
|
||||
import { Suggestion } from '@/lib/db/schema';
|
||||
|
||||
export interface UISuggestion extends Suggestion {
|
||||
selectionStart: number;
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ import {
|
||||
import { clsx, type ClassValue } from 'clsx';
|
||||
import { twMerge } from 'tailwind-merge';
|
||||
|
||||
import { Message as DBMessage, Document } from '@/db/schema';
|
||||
import { Message as DBMessage, Document } from '@/lib/db/schema';
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs));
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
"lint:fix": "next lint --fix",
|
||||
"format": "prettier --write .",
|
||||
"db:generate": "drizzle-kit generate",
|
||||
"db:migrate": "npx tsx db/migrate.ts",
|
||||
"db:migrate": "npx tsx lib/db/migrate.ts",
|
||||
"db:studio": "drizzle-kit studio"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
"isolatedModules": true,
|
||||
"jsx": "preserve",
|
||||
"incremental": true,
|
||||
"baseUrl": ".",
|
||||
"plugins": [
|
||||
{
|
||||
"name": "next"
|
||||
|
||||
Reference in New Issue
Block a user