32 lines
804 B
TypeScript
32 lines
804 B
TypeScript
import { closeDb, getDb } from "@/db";
|
|
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();
|