@opprs/db-prisma 2.2.1-canary.3bbfda2 → 2.2.1-canary.4bd4fa2
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/dist/index.cjs +1233 -158
- package/dist/index.d.cts +1028 -106
- package/dist/index.d.ts +1028 -106
- package/dist/index.js +1117 -141
- package/package.json +2 -2
- package/prisma/migrations/20260104000000_add_player_number/migration.sql +23 -0
- package/prisma/migrations/20260104092800_add_location_model_and_tournament_fields/migration.sql +45 -0
- package/prisma/migrations/20260104210034_add_policy_acceptance_fields/migration.sql +19 -0
- package/prisma/migrations/20260104231435_split_entries_standings/migration.sql +137 -0
- package/prisma/migrations/20260105000000_add_oppr_ranking_models/migration.sql +108 -0
- package/prisma/migrations/20260105010000_add_qualifying_format/migration.sql +5 -0
- package/prisma/migrations/20260105010000_add_tournament_external_url/migration.sql +2 -0
- package/prisma/schema.prisma +309 -37
- package/prisma/seed.ts +112 -35
package/prisma/seed.ts
CHANGED
|
@@ -13,51 +13,45 @@ async function main() {
|
|
|
13
13
|
const playerData = [
|
|
14
14
|
{
|
|
15
15
|
externalId: 'player-1',
|
|
16
|
+
playerNumber: 10001,
|
|
16
17
|
name: 'Alice Champion',
|
|
17
|
-
rating: 1850,
|
|
18
|
-
ratingDeviation: 50,
|
|
19
|
-
ranking: 5,
|
|
20
|
-
isRated: true,
|
|
21
18
|
eventCount: 25,
|
|
22
19
|
},
|
|
23
20
|
{
|
|
24
21
|
externalId: 'player-2',
|
|
22
|
+
playerNumber: 10002,
|
|
25
23
|
name: 'Bob Wizard',
|
|
26
|
-
rating: 1750,
|
|
27
|
-
ratingDeviation: 60,
|
|
28
|
-
ranking: 12,
|
|
29
|
-
isRated: true,
|
|
30
24
|
eventCount: 18,
|
|
31
25
|
},
|
|
32
26
|
{
|
|
33
27
|
externalId: 'player-3',
|
|
28
|
+
playerNumber: 10003,
|
|
34
29
|
name: 'Charlie Flipper',
|
|
35
|
-
rating: 1650,
|
|
36
|
-
ratingDeviation: 75,
|
|
37
|
-
ranking: 28,
|
|
38
|
-
isRated: true,
|
|
39
30
|
eventCount: 12,
|
|
40
31
|
},
|
|
41
32
|
{
|
|
42
33
|
externalId: 'player-4',
|
|
34
|
+
playerNumber: 10004,
|
|
43
35
|
name: 'Diana Tilt',
|
|
44
|
-
rating: 1550,
|
|
45
|
-
ratingDeviation: 100,
|
|
46
|
-
ranking: 45,
|
|
47
|
-
isRated: true,
|
|
48
36
|
eventCount: 8,
|
|
49
37
|
},
|
|
50
38
|
{
|
|
51
39
|
externalId: 'player-5',
|
|
40
|
+
playerNumber: 10005,
|
|
52
41
|
name: 'Eve Plunger',
|
|
53
|
-
rating: 1300,
|
|
54
|
-
ratingDeviation: 150,
|
|
55
|
-
ranking: null,
|
|
56
|
-
isRated: false,
|
|
57
42
|
eventCount: 3,
|
|
58
43
|
},
|
|
59
44
|
];
|
|
60
45
|
|
|
46
|
+
// OPPR ranking data for each player
|
|
47
|
+
const rankingData = [
|
|
48
|
+
{ rating: 1850, ratingDeviation: 50, ranking: 5, isRated: true },
|
|
49
|
+
{ rating: 1750, ratingDeviation: 60, ranking: 12, isRated: true },
|
|
50
|
+
{ rating: 1650, ratingDeviation: 75, ranking: 28, isRated: true },
|
|
51
|
+
{ rating: 1550, ratingDeviation: 100, ranking: 45, isRated: true },
|
|
52
|
+
{ rating: 1300, ratingDeviation: 150, ranking: null, isRated: false },
|
|
53
|
+
];
|
|
54
|
+
|
|
61
55
|
const player1 = await prisma.player.upsert({
|
|
62
56
|
where: { externalId: 'player-1' },
|
|
63
57
|
update: playerData[0],
|
|
@@ -90,6 +84,18 @@ async function main() {
|
|
|
90
84
|
|
|
91
85
|
console.log(`✓ Created ${await prisma.player.count()} players`);
|
|
92
86
|
|
|
87
|
+
// Create OPPR rankings for each player
|
|
88
|
+
console.log('Creating OPPR rankings...');
|
|
89
|
+
const players = [player1, player2, player3, player4, player5];
|
|
90
|
+
for (let i = 0; i < players.length; i++) {
|
|
91
|
+
await prisma.opprPlayerRanking.upsert({
|
|
92
|
+
where: { playerId: players[i].id },
|
|
93
|
+
update: rankingData[i],
|
|
94
|
+
create: { playerId: players[i].id, ...rankingData[i] },
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
console.log(`✓ Created ${await prisma.opprPlayerRanking.count()} OPPR rankings`);
|
|
98
|
+
|
|
93
99
|
// Seed users from environment variables (development only)
|
|
94
100
|
const seedAdminEmail = process.env.SEED_ADMIN_EMAIL;
|
|
95
101
|
const seedAdminPassword = process.env.SEED_ADMIN_PASSWORD;
|
|
@@ -144,13 +150,71 @@ async function main() {
|
|
|
144
150
|
|
|
145
151
|
console.log(`✓ Created admin user (admin@example.com / ${adminPassword})`);
|
|
146
152
|
|
|
153
|
+
// Create sample locations (using upsert for idempotency)
|
|
154
|
+
console.log('Creating locations...');
|
|
155
|
+
|
|
156
|
+
const location1 = await prisma.location.upsert({
|
|
157
|
+
where: { externalId: 'location-1' },
|
|
158
|
+
update: {
|
|
159
|
+
name: 'Las Vegas Convention Center',
|
|
160
|
+
city: 'Las Vegas',
|
|
161
|
+
state: 'NV',
|
|
162
|
+
country: 'USA',
|
|
163
|
+
},
|
|
164
|
+
create: {
|
|
165
|
+
externalId: 'location-1',
|
|
166
|
+
name: 'Las Vegas Convention Center',
|
|
167
|
+
city: 'Las Vegas',
|
|
168
|
+
state: 'NV',
|
|
169
|
+
country: 'USA',
|
|
170
|
+
},
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
const location2 = await prisma.location.upsert({
|
|
174
|
+
where: { externalId: 'location-2' },
|
|
175
|
+
update: {
|
|
176
|
+
name: 'Ground Kontrol',
|
|
177
|
+
address: '115 NW 5th Ave',
|
|
178
|
+
city: 'Portland',
|
|
179
|
+
state: 'OR',
|
|
180
|
+
country: 'USA',
|
|
181
|
+
},
|
|
182
|
+
create: {
|
|
183
|
+
externalId: 'location-2',
|
|
184
|
+
name: 'Ground Kontrol',
|
|
185
|
+
address: '115 NW 5th Ave',
|
|
186
|
+
city: 'Portland',
|
|
187
|
+
state: 'OR',
|
|
188
|
+
country: 'USA',
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
const location3 = await prisma.location.upsert({
|
|
193
|
+
where: { externalId: 'location-3' },
|
|
194
|
+
update: {
|
|
195
|
+
name: 'Add-a-Ball Amusements',
|
|
196
|
+
city: 'Seattle',
|
|
197
|
+
state: 'WA',
|
|
198
|
+
country: 'USA',
|
|
199
|
+
},
|
|
200
|
+
create: {
|
|
201
|
+
externalId: 'location-3',
|
|
202
|
+
name: 'Add-a-Ball Amusements',
|
|
203
|
+
city: 'Seattle',
|
|
204
|
+
state: 'WA',
|
|
205
|
+
country: 'USA',
|
|
206
|
+
},
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
console.log(`✓ Created ${await prisma.location.count()} locations`);
|
|
210
|
+
|
|
147
211
|
// Create sample tournaments (using upsert for idempotency)
|
|
148
212
|
console.log('Creating tournaments...');
|
|
149
213
|
|
|
150
214
|
const tournament1Data = {
|
|
151
215
|
externalId: 'tournament-1',
|
|
152
216
|
name: 'World Pinball Championship 2024',
|
|
153
|
-
|
|
217
|
+
locationId: location1.id,
|
|
154
218
|
date: new Date('2024-03-15'),
|
|
155
219
|
eventBooster: EventBoosterType.MAJOR,
|
|
156
220
|
allowsOptOut: false,
|
|
@@ -186,7 +250,7 @@ async function main() {
|
|
|
186
250
|
const tournament2Data = {
|
|
187
251
|
externalId: 'tournament-2',
|
|
188
252
|
name: 'Spring Classics 2024',
|
|
189
|
-
|
|
253
|
+
locationId: location2.id,
|
|
190
254
|
date: new Date('2024-04-20'),
|
|
191
255
|
eventBooster: EventBoosterType.CERTIFIED,
|
|
192
256
|
allowsOptOut: true,
|
|
@@ -220,7 +284,7 @@ async function main() {
|
|
|
220
284
|
const tournament3Data = {
|
|
221
285
|
externalId: 'tournament-3',
|
|
222
286
|
name: 'Monthly League Finals',
|
|
223
|
-
|
|
287
|
+
locationId: location3.id,
|
|
224
288
|
date: new Date('2024-05-10'),
|
|
225
289
|
eventBooster: EventBoosterType.NONE,
|
|
226
290
|
allowsOptOut: false,
|
|
@@ -253,11 +317,11 @@ async function main() {
|
|
|
253
317
|
|
|
254
318
|
console.log(`✓ Created ${await prisma.tournament.count()} tournaments`);
|
|
255
319
|
|
|
256
|
-
// Create tournament
|
|
257
|
-
console.log('Creating tournament
|
|
320
|
+
// Create tournament standings (delete existing first for idempotency)
|
|
321
|
+
console.log('Creating tournament standings...');
|
|
258
322
|
|
|
259
|
-
// Delete existing
|
|
260
|
-
await prisma.
|
|
323
|
+
// Delete existing standings for seeded tournaments
|
|
324
|
+
await prisma.standing.deleteMany({
|
|
261
325
|
where: {
|
|
262
326
|
tournamentId: {
|
|
263
327
|
in: [tournament1.id, tournament2.id, tournament3.id],
|
|
@@ -265,13 +329,14 @@ async function main() {
|
|
|
265
329
|
},
|
|
266
330
|
});
|
|
267
331
|
|
|
268
|
-
// World Championship
|
|
269
|
-
await prisma.
|
|
332
|
+
// World Championship standings
|
|
333
|
+
await prisma.standing.createMany({
|
|
270
334
|
data: [
|
|
271
335
|
{
|
|
272
336
|
playerId: player1.id,
|
|
273
337
|
tournamentId: tournament1.id,
|
|
274
338
|
position: 1,
|
|
339
|
+
isFinals: true,
|
|
275
340
|
totalPoints: 411.84,
|
|
276
341
|
linearPoints: 41.18,
|
|
277
342
|
dynamicPoints: 370.66,
|
|
@@ -284,6 +349,7 @@ async function main() {
|
|
|
284
349
|
playerId: player2.id,
|
|
285
350
|
tournamentId: tournament1.id,
|
|
286
351
|
position: 2,
|
|
352
|
+
isFinals: true,
|
|
287
353
|
totalPoints: 298.45,
|
|
288
354
|
linearPoints: 41.18,
|
|
289
355
|
dynamicPoints: 257.27,
|
|
@@ -296,6 +362,7 @@ async function main() {
|
|
|
296
362
|
playerId: player3.id,
|
|
297
363
|
tournamentId: tournament1.id,
|
|
298
364
|
position: 3,
|
|
365
|
+
isFinals: true,
|
|
299
366
|
totalPoints: 215.32,
|
|
300
367
|
linearPoints: 41.18,
|
|
301
368
|
dynamicPoints: 174.14,
|
|
@@ -308,6 +375,7 @@ async function main() {
|
|
|
308
375
|
playerId: player4.id,
|
|
309
376
|
tournamentId: tournament1.id,
|
|
310
377
|
position: 5,
|
|
378
|
+
isFinals: true,
|
|
311
379
|
totalPoints: 125.18,
|
|
312
380
|
linearPoints: 41.18,
|
|
313
381
|
dynamicPoints: 84.00,
|
|
@@ -319,13 +387,14 @@ async function main() {
|
|
|
319
387
|
],
|
|
320
388
|
});
|
|
321
389
|
|
|
322
|
-
// Spring Classics
|
|
323
|
-
await prisma.
|
|
390
|
+
// Spring Classics standings
|
|
391
|
+
await prisma.standing.createMany({
|
|
324
392
|
data: [
|
|
325
393
|
{
|
|
326
394
|
playerId: player2.id,
|
|
327
395
|
tournamentId: tournament2.id,
|
|
328
396
|
position: 1,
|
|
397
|
+
isFinals: true,
|
|
329
398
|
totalPoints: 87.28,
|
|
330
399
|
linearPoints: 8.73,
|
|
331
400
|
dynamicPoints: 78.55,
|
|
@@ -338,6 +407,7 @@ async function main() {
|
|
|
338
407
|
playerId: player1.id,
|
|
339
408
|
tournamentId: tournament2.id,
|
|
340
409
|
position: 2,
|
|
410
|
+
isFinals: true,
|
|
341
411
|
totalPoints: 63.25,
|
|
342
412
|
linearPoints: 8.73,
|
|
343
413
|
dynamicPoints: 54.52,
|
|
@@ -350,6 +420,7 @@ async function main() {
|
|
|
350
420
|
playerId: player4.id,
|
|
351
421
|
tournamentId: tournament2.id,
|
|
352
422
|
position: 3,
|
|
423
|
+
isFinals: true,
|
|
353
424
|
totalPoints: 45.67,
|
|
354
425
|
linearPoints: 8.73,
|
|
355
426
|
dynamicPoints: 36.94,
|
|
@@ -362,6 +433,7 @@ async function main() {
|
|
|
362
433
|
playerId: player5.id,
|
|
363
434
|
tournamentId: tournament2.id,
|
|
364
435
|
position: 6,
|
|
436
|
+
isFinals: true,
|
|
365
437
|
totalPoints: 18.52,
|
|
366
438
|
linearPoints: 8.73,
|
|
367
439
|
dynamicPoints: 9.79,
|
|
@@ -373,13 +445,14 @@ async function main() {
|
|
|
373
445
|
],
|
|
374
446
|
});
|
|
375
447
|
|
|
376
|
-
// Monthly League
|
|
377
|
-
await prisma.
|
|
448
|
+
// Monthly League standings
|
|
449
|
+
await prisma.standing.createMany({
|
|
378
450
|
data: [
|
|
379
451
|
{
|
|
380
452
|
playerId: player3.id,
|
|
381
453
|
tournamentId: tournament3.id,
|
|
382
454
|
position: 1,
|
|
455
|
+
isFinals: true,
|
|
383
456
|
totalPoints: 28.4,
|
|
384
457
|
linearPoints: 2.84,
|
|
385
458
|
dynamicPoints: 25.56,
|
|
@@ -392,6 +465,7 @@ async function main() {
|
|
|
392
465
|
playerId: player4.id,
|
|
393
466
|
tournamentId: tournament3.id,
|
|
394
467
|
position: 2,
|
|
468
|
+
isFinals: true,
|
|
395
469
|
totalPoints: 20.58,
|
|
396
470
|
linearPoints: 2.84,
|
|
397
471
|
dynamicPoints: 17.74,
|
|
@@ -404,6 +478,7 @@ async function main() {
|
|
|
404
478
|
playerId: player5.id,
|
|
405
479
|
tournamentId: tournament3.id,
|
|
406
480
|
position: 3,
|
|
481
|
+
isFinals: true,
|
|
407
482
|
totalPoints: 14.85,
|
|
408
483
|
linearPoints: 2.84,
|
|
409
484
|
dynamicPoints: 12.01,
|
|
@@ -415,16 +490,18 @@ async function main() {
|
|
|
415
490
|
],
|
|
416
491
|
});
|
|
417
492
|
|
|
418
|
-
console.log(`✓ Created ${await prisma.
|
|
493
|
+
console.log(`✓ Created ${await prisma.standing.count()} tournament standings`);
|
|
419
494
|
|
|
420
495
|
console.log('');
|
|
421
496
|
console.log('✅ Database seeded successfully!');
|
|
422
497
|
console.log('');
|
|
423
498
|
console.log('Summary:');
|
|
424
499
|
console.log(` - ${await prisma.player.count()} players`);
|
|
500
|
+
console.log(` - ${await prisma.opprPlayerRanking.count()} OPPR rankings`);
|
|
425
501
|
console.log(` - ${await prisma.user.count()} users`);
|
|
502
|
+
console.log(` - ${await prisma.location.count()} locations`);
|
|
426
503
|
console.log(` - ${await prisma.tournament.count()} tournaments`);
|
|
427
|
-
console.log(` - ${await prisma.
|
|
504
|
+
console.log(` - ${await prisma.standing.count()} standings`);
|
|
428
505
|
}
|
|
429
506
|
|
|
430
507
|
main()
|