feat(prisma): add db:resetadmin and db:setup scripts for database management

This commit is contained in:
Fatih Kadir Akın
2026-01-06 10:47:08 +03:00
parent 4e4d170b94
commit 9296d2c2f6
5 changed files with 434 additions and 904 deletions

View File

@@ -0,0 +1,3 @@
-- AlterTable
ALTER TABLE "users" ALTER COLUMN "dailyGenerationLimit" SET DEFAULT 3,
ALTER COLUMN "generationCreditsRemaining" SET DEFAULT 3;

40
prisma/reset-admin.ts Normal file
View File

@@ -0,0 +1,40 @@
import { PrismaClient } from "@prisma/client";
import bcrypt from "bcryptjs";
const prisma = new PrismaClient();
async function main() {
console.log("🔐 Resetting admin user...");
const password = await bcrypt.hash("password123", 12);
const admin = await prisma.user.upsert({
where: { email: "admin@prompts.chat" },
update: {
password: password,
role: "ADMIN",
},
create: {
email: "admin@prompts.chat",
username: "admin",
name: "Admin User",
password: password,
role: "ADMIN",
locale: "en",
},
});
console.log("✅ Admin user reset successfully!");
console.log("\n📋 Credentials:");
console.log(" Email: admin@prompts.chat");
console.log(" Password: password123");
}
main()
.catch((e) => {
console.error("❌ Failed to reset admin:", e);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});

File diff suppressed because it is too large Load Diff