Files
buzz-sheet/scripts/seed-templates.ts
T

32 lines
811 B
TypeScript

import { closeDb, getDb } from "@/db/client";
import { templates } from "@/db/schema";
import { builtInTemplates } from "@/lib/templates";
const db = getDb();
for (const template of builtInTemplates) {
await db
.insert(templates)
.values({
slug: template.slug,
name: template.name,
description: template.description,
category: template.category,
structure: template as unknown as Record<string, unknown>,
builtIn: true,
})
.onConflictDoUpdate({
target: templates.slug,
set: {
name: template.name,
description: template.description,
category: template.category,
structure: template as unknown as Record<string, unknown>,
builtIn: true,
updatedAt: new Date(),
},
});
}
await closeDb();