mirror of
https://github.com/sqlchat/sqlchat.git
synced 2025-09-25 09:03:43 +08:00
chore: update usage database schema
This commit is contained in:
@ -1,70 +1,61 @@
|
||||
import { PrismaClient, Prisma } from '@prisma/client'
|
||||
import { PrismaClient, Prisma } from "@prisma/client";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
|
||||
const prisma = new PrismaClient()
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
const chatData: Prisma.ChatCreateInput[] = [
|
||||
{
|
||||
id: uuidv4(),
|
||||
createdAt: new Date(),
|
||||
ctx: {},
|
||||
prompts: {
|
||||
messages: {
|
||||
create: [
|
||||
{
|
||||
id: uuidv4(),
|
||||
createdAt: new Date(),
|
||||
q: "Hello",
|
||||
a: "What can I help you with today?",
|
||||
role: "system",
|
||||
content: "You are a bot",
|
||||
upvote: true,
|
||||
downvote: false,
|
||||
},
|
||||
{
|
||||
id: uuidv4(),
|
||||
createdAt: new Date(),
|
||||
q: "How are you?",
|
||||
a: "Fine, thank you, and you?",
|
||||
role: "user",
|
||||
content: "What can I help you with today?",
|
||||
upvote: true,
|
||||
downvote: false,
|
||||
},
|
||||
{
|
||||
id: uuidv4(),
|
||||
createdAt: new Date(),
|
||||
role: "assistant",
|
||||
content: "Hello",
|
||||
upvote: true,
|
||||
downvote: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: uuidv4(),
|
||||
createdAt: new Date(),
|
||||
ctx: {},
|
||||
prompts: {
|
||||
create: [
|
||||
{
|
||||
id: uuidv4(),
|
||||
createdAt: new Date(),
|
||||
q: "Tell me a joke",
|
||||
a: "What do you call a fake noodle? An Impasta.",
|
||||
upvote: true,
|
||||
downvote: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
];
|
||||
|
||||
async function main() {
|
||||
console.log(`Start seeding ...`)
|
||||
console.log(`Start seeding ...`);
|
||||
for (const c of chatData) {
|
||||
const chat = await prisma.chat.create({
|
||||
data: c,
|
||||
})
|
||||
console.log(`Created chat with id: ${chat.id}`)
|
||||
});
|
||||
console.log(`Created chat with id: ${chat.id}`);
|
||||
}
|
||||
console.log(`Seeding finished.`)
|
||||
console.log(`Seeding finished.`);
|
||||
}
|
||||
|
||||
main()
|
||||
.then(async () => {
|
||||
await prisma.$disconnect()
|
||||
await prisma.$disconnect();
|
||||
})
|
||||
.catch(async (e) => {
|
||||
console.error(e)
|
||||
await prisma.$disconnect()
|
||||
process.exit(1)
|
||||
})
|
||||
console.error(e);
|
||||
await prisma.$disconnect();
|
||||
process.exit(1);
|
||||
});
|
||||
|
Reference in New Issue
Block a user