Skip to content

Commit

Permalink
feat: update prompt migrate
Browse files Browse the repository at this point in the history
  • Loading branch information
darkskygit committed Apr 16, 2024
1 parent d9de74f commit c055a8e
Showing 1 changed file with 2 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,31 +1,11 @@
import { PrismaClient } from '@prisma/client';

import { prompts } from './utils/prompts';
import { refreshPrompts } from './utils/prompts';

export class Prompts1712068777394 {
// do the migration
static async up(db: PrismaClient) {
await db.$transaction(async tx => {
await Promise.all(
prompts.map(prompt =>
tx.aiPrompt.create({
data: {
name: prompt.name,
action: prompt.action,
model: prompt.model,
messages: {
create: prompt.messages.map((message, idx) => ({
idx,
role: message.role,
content: message.content,
params: message.params,
})),
},
},
})
)
);
});
await refreshPrompts(db);
}

// revert the migration
Expand Down

0 comments on commit c055a8e

Please sign in to comment.