49 lines
1.4 KiB
TypeScript
49 lines
1.4 KiB
TypeScript
import "dotenv/config";
|
|
import { PrismaClient } from "../src/generated/prisma/client";
|
|
import { PrismaPg } from "@prisma/adapter-pg";
|
|
import bcrypt from "bcryptjs";
|
|
|
|
const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL! });
|
|
const prisma = new PrismaClient({ adapter });
|
|
|
|
async function main() {
|
|
const username = process.env.ADMIN_USERNAME || "admin";
|
|
const password = process.env.ADMIN_PASSWORD || "admin123";
|
|
const passwordHash = await bcrypt.hash(password, 12);
|
|
|
|
await prisma.admin.upsert({
|
|
where: { username },
|
|
update: { passwordHash },
|
|
create: { username, passwordHash },
|
|
});
|
|
|
|
console.log(`Admin user "${username}" created/updated.`);
|
|
|
|
const existingAddon = await prisma.addon.findUnique({
|
|
where: { slug: "nanami" },
|
|
});
|
|
|
|
if (!existingAddon) {
|
|
await prisma.addon.create({
|
|
data: {
|
|
name: "Nanami",
|
|
slug: "nanami",
|
|
summary: "A powerful WoW addon that enhances your gameplay experience.",
|
|
description:
|
|
"# Nanami\n\nNanami is a comprehensive World of Warcraft addon designed to improve your gaming experience.\n\n## Features\n\n- Feature 1\n- Feature 2\n- Feature 3",
|
|
category: "gameplay",
|
|
published: true,
|
|
},
|
|
});
|
|
console.log("Sample addon 'Nanami' created.");
|
|
}
|
|
}
|
|
|
|
main()
|
|
.then(() => prisma.$disconnect())
|
|
.catch(async (e) => {
|
|
console.error(e);
|
|
await prisma.$disconnect();
|
|
process.exit(1);
|
|
});
|