diff --git a/prisma/seed.ts b/prisma/seed.ts index 1e214fd14..c69ba3c0b 100644 --- a/prisma/seed.ts +++ b/prisma/seed.ts @@ -1,8 +1,30 @@ import { PrismaClient } from "@prisma/client"; +const fs = require("fs"); +const path = require("path"); const prisma = new PrismaClient(); const main = async () => { + fs.readFile(path.join(__dirname, "/.env"), function (err: any, data: any) { + if (!err) { + for (const line of data.toString().split("\n")) { + if (!line.startsWith("DATABASE_URL=")) { + continue; + } + + if (!line.includes("localhost:")) { + console.error("trying to seed a database not in localhost"); + process.exit(1); + } + } + } else { + console.error(err); + process.exit(1); + } + }); + + await prisma.profile.deleteMany({}); + await prisma.user.deleteMany({}); await prisma.user.create({ data: { username: "N-ZAP", @@ -22,6 +44,7 @@ const main = async () => { "Luna Blaster", "N-ZAP '89", ], + twitterName: "nintendovs", twitchName: "nintendo", youtubeId: "UCAtobAxsQcACwDZCSH9uJfA", },