@opprs/db-prisma 2.2.1-canary.c7c3fc7 → 2.2.1-canary.d052ffb
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/prisma/seed.ts +33 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opprs/db-prisma",
|
|
3
|
-
"version": "2.2.1-canary.
|
|
3
|
+
"version": "2.2.1-canary.d052ffb",
|
|
4
4
|
"description": "Database backend for OPPR (Open Pinball Player Ranking System) using Prisma and PostgreSQL",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"oppr",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"vitest": "^4.0.16"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@opprs/core": "^2.2.1-canary.
|
|
59
|
+
"@opprs/core": "^2.2.1-canary.d052ffb"
|
|
60
60
|
},
|
|
61
61
|
"engines": {
|
|
62
62
|
"node": ">=20.9.0"
|
package/prisma/seed.ts
CHANGED
|
@@ -90,27 +90,39 @@ async function main() {
|
|
|
90
90
|
|
|
91
91
|
console.log(`✓ Created ${await prisma.player.count()} players`);
|
|
92
92
|
|
|
93
|
-
//
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
email: '
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
|
|
93
|
+
// Seed users from environment variables (development only)
|
|
94
|
+
const seedAdminEmail = process.env.SEED_ADMIN_EMAIL;
|
|
95
|
+
const seedAdminPassword = process.env.SEED_ADMIN_PASSWORD;
|
|
96
|
+
const seedTestEmail = process.env.SEED_TEST_EMAIL;
|
|
97
|
+
const seedTestPassword = process.env.SEED_TEST_PASSWORD;
|
|
98
|
+
|
|
99
|
+
// Create admin user if credentials provided
|
|
100
|
+
if (seedAdminEmail && seedAdminPassword) {
|
|
101
|
+
console.log('Creating admin user...');
|
|
102
|
+
const adminPasswordHash = await bcrypt.hash(seedAdminPassword, BCRYPT_SALT_ROUNDS);
|
|
103
|
+
await prisma.user.upsert({
|
|
104
|
+
where: { email: seedAdminEmail },
|
|
105
|
+
update: { passwordHash: adminPasswordHash, role: 'ADMIN' },
|
|
106
|
+
create: { email: seedAdminEmail, passwordHash: adminPasswordHash, role: 'ADMIN' },
|
|
107
|
+
});
|
|
108
|
+
console.log(`✓ Created admin user (${seedAdminEmail})`);
|
|
109
|
+
} else {
|
|
110
|
+
console.log('⏭ Skipping admin user (SEED_ADMIN_EMAIL/SEED_ADMIN_PASSWORD not set)');
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Create test user if credentials provided (linked to Alice Champion)
|
|
114
|
+
if (seedTestEmail && seedTestPassword) {
|
|
115
|
+
console.log('Creating test user...');
|
|
116
|
+
const testPasswordHash = await bcrypt.hash(seedTestPassword, BCRYPT_SALT_ROUNDS);
|
|
117
|
+
await prisma.user.upsert({
|
|
118
|
+
where: { email: seedTestEmail },
|
|
119
|
+
update: { passwordHash: testPasswordHash, role: 'USER', playerId: player1.id },
|
|
120
|
+
create: { email: seedTestEmail, passwordHash: testPasswordHash, role: 'USER', playerId: player1.id },
|
|
121
|
+
});
|
|
122
|
+
console.log(`✓ Created test user (${seedTestEmail}) linked to ${player1.name}`);
|
|
123
|
+
} else {
|
|
124
|
+
console.log('⏭ Skipping test user (SEED_TEST_EMAIL/SEED_TEST_PASSWORD not set)');
|
|
125
|
+
}
|
|
114
126
|
|
|
115
127
|
// Create admin user
|
|
116
128
|
console.log('Creating admin user...');
|