mirror of
https://github.com/f/awesome-chatgpt-prompts.git
synced 2026-03-03 03:07:00 +00:00
feat(prisma): add db:resetadmin and db:setup scripts for database management
This commit is contained in:
3
prisma/migrations/20260106071035/migration.sql
Normal file
3
prisma/migrations/20260106071035/migration.sql
Normal 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
40
prisma/reset-admin.ts
Normal 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();
|
||||
});
|
||||
1095
prisma/seed.ts
1095
prisma/seed.ts
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user