@opprs/db-prisma 2.2.1-canary.5233c68 → 2.2.1-canary.55cd794
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
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.55cd794",
|
|
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.55cd794"
|
|
60
60
|
},
|
|
61
61
|
"engines": {
|
|
62
62
|
"node": ">=20.9.0"
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
-- AlterTable
|
|
2
|
+
-- First add playerNumber as nullable, populate it, then make it required
|
|
3
|
+
ALTER TABLE "Player" ADD COLUMN "playerNumber" INTEGER;
|
|
4
|
+
|
|
5
|
+
-- Populate existing players with unique 5-digit player numbers
|
|
6
|
+
-- Use a sequence starting from 10000, incrementing for each existing row
|
|
7
|
+
WITH numbered_players AS (
|
|
8
|
+
SELECT id, ROW_NUMBER() OVER (ORDER BY "createdAt") + 9999 AS num
|
|
9
|
+
FROM "Player"
|
|
10
|
+
)
|
|
11
|
+
UPDATE "Player"
|
|
12
|
+
SET "playerNumber" = numbered_players.num::INTEGER
|
|
13
|
+
FROM numbered_players
|
|
14
|
+
WHERE "Player".id = numbered_players.id;
|
|
15
|
+
|
|
16
|
+
-- Make the column required and add unique constraint
|
|
17
|
+
ALTER TABLE "Player" ALTER COLUMN "playerNumber" SET NOT NULL;
|
|
18
|
+
|
|
19
|
+
-- CreateIndex
|
|
20
|
+
CREATE UNIQUE INDEX "Player_playerNumber_key" ON "Player"("playerNumber");
|
|
21
|
+
|
|
22
|
+
-- CreateIndex
|
|
23
|
+
CREATE INDEX "Player_playerNumber_idx" ON "Player"("playerNumber");
|
package/prisma/seed.ts
CHANGED
|
@@ -13,6 +13,7 @@ async function main() {
|
|
|
13
13
|
const playerData = [
|
|
14
14
|
{
|
|
15
15
|
externalId: 'player-1',
|
|
16
|
+
playerNumber: 10001,
|
|
16
17
|
name: 'Alice Champion',
|
|
17
18
|
rating: 1850,
|
|
18
19
|
ratingDeviation: 50,
|
|
@@ -22,6 +23,7 @@ async function main() {
|
|
|
22
23
|
},
|
|
23
24
|
{
|
|
24
25
|
externalId: 'player-2',
|
|
26
|
+
playerNumber: 10002,
|
|
25
27
|
name: 'Bob Wizard',
|
|
26
28
|
rating: 1750,
|
|
27
29
|
ratingDeviation: 60,
|
|
@@ -31,6 +33,7 @@ async function main() {
|
|
|
31
33
|
},
|
|
32
34
|
{
|
|
33
35
|
externalId: 'player-3',
|
|
36
|
+
playerNumber: 10003,
|
|
34
37
|
name: 'Charlie Flipper',
|
|
35
38
|
rating: 1650,
|
|
36
39
|
ratingDeviation: 75,
|
|
@@ -40,6 +43,7 @@ async function main() {
|
|
|
40
43
|
},
|
|
41
44
|
{
|
|
42
45
|
externalId: 'player-4',
|
|
46
|
+
playerNumber: 10004,
|
|
43
47
|
name: 'Diana Tilt',
|
|
44
48
|
rating: 1550,
|
|
45
49
|
ratingDeviation: 100,
|
|
@@ -49,6 +53,7 @@ async function main() {
|
|
|
49
53
|
},
|
|
50
54
|
{
|
|
51
55
|
externalId: 'player-5',
|
|
56
|
+
playerNumber: 10005,
|
|
52
57
|
name: 'Eve Plunger',
|
|
53
58
|
rating: 1300,
|
|
54
59
|
ratingDeviation: 150,
|
|
@@ -144,26 +149,6 @@ async function main() {
|
|
|
144
149
|
|
|
145
150
|
console.log(`✓ Created admin user (admin@example.com / ${adminPassword})`);
|
|
146
151
|
|
|
147
|
-
// Create admin user
|
|
148
|
-
console.log('Creating admin user...');
|
|
149
|
-
const adminPassword = 'AdminPassword123!';
|
|
150
|
-
const adminPasswordHash = await bcrypt.hash(adminPassword, BCRYPT_SALT_ROUNDS);
|
|
151
|
-
|
|
152
|
-
await prisma.user.upsert({
|
|
153
|
-
where: { email: 'admin@example.com' },
|
|
154
|
-
update: {
|
|
155
|
-
passwordHash: adminPasswordHash,
|
|
156
|
-
role: 'ADMIN',
|
|
157
|
-
},
|
|
158
|
-
create: {
|
|
159
|
-
email: 'admin@example.com',
|
|
160
|
-
passwordHash: adminPasswordHash,
|
|
161
|
-
role: 'ADMIN',
|
|
162
|
-
},
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
console.log(`✓ Created admin user (admin@example.com / ${adminPassword})`);
|
|
166
|
-
|
|
167
152
|
// Create sample tournaments (using upsert for idempotency)
|
|
168
153
|
console.log('Creating tournaments...');
|
|
169
154
|
|