Spaces:
Build error

File size: 1,784 Bytes
dae886b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76

import { PrismaClient } from "@prisma/client";
import bcrypt from "bcryptjs";

const prisma = new PrismaClient();

async function main() {
  const passwordHash = await bcrypt.hash("password123", 10);

  // Create Admin
  try {
    const admin = await prisma.user.upsert({
      where: { email: "admin@primestake.com" },
      update: {
        isVerified: true,
        passwordHash // Update password in case it changed
      },
      create: {
        username: "admin",
        email: "admin@primestake.com",
        passwordHash,
        role: "ADMIN",
        isVerified: true,
        wallet: {
          create: {
            balance: 10000,
            currency: "INR"
          }
        }
      }
    });
    console.log("Admin User Ready:");
    console.log("Email: admin@primestake.com");
    console.log("Username: admin");
    console.log("Password: password123");
  } catch (e) {
    console.error("Error creating admin:", e.message);
  }

  // Create Player
  try {
    const player = await prisma.user.upsert({
      where: { email: "player@primestake.com" },
      update: {
        isVerified: true,
        passwordHash
      },
      create: {
        username: "player",
        email: "player@primestake.com",
        passwordHash,
        role: "USER",
        isVerified: true,
        wallet: {
          create: {
            balance: 500,
            currency: "INR"
          }
        }
      }
    });
    console.log("\nPlayer User Ready:");
    console.log("Email: player@primestake.com");
    console.log("Username: player");
    console.log("Password: password123");
  } catch (e) {
    console.error("Error creating player:", e.message);
  }
}

main()
  .catch(e => console.error(e))
  .finally(async () => {
    await prisma.$disconnect();
  });