mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-09-29 14:50:13 -05:00
more advanced seed ts
This commit is contained in:
@@ -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",
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user