diff --git a/web/dbml/schema.dbml b/web/dbml/schema.dbml index 493168e..f5a959f 100644 --- a/web/dbml/schema.dbml +++ b/web/dbml/schema.dbml @@ -6,8 +6,8 @@ Table Borrow { id Int [pk, increment] userLogin String [not null] joyconsTaken Int [not null] - borrowOpeningId Int [unique, not null] - returnOpeningId Int [unique, not null] + borrowOpeningId String [unique, not null] + returnOpeningId String [unique, not null] createdAt DateTime [default: `now()`, not null] user User [not null] borrowOpening Opening [not null] @@ -15,7 +15,7 @@ Table Borrow { } Table Opening { - id Int [pk, increment] + id String [pk] date DateTime code String codeGeneratedAt DateTime diff --git a/web/src/utils.ts b/web/src/utils.ts index 341d789..746205d 100644 --- a/web/src/utils.ts +++ b/web/src/utils.ts @@ -143,7 +143,7 @@ export async function getWaitingOpeningWithValidCode(userLogin: string) { return formatOpening(opening); } -export async function generateNewCode(borrowId: number) { +export async function generateNewCode(borrowId: string) { const code = await generateCode(); await prisma.opening.update({ where: { id: borrowId }, diff --git a/web/src/webRouter.ts b/web/src/webRouter.ts index b3cff50..e2c5fa5 100644 --- a/web/src/webRouter.ts +++ b/web/src/webRouter.ts @@ -145,7 +145,7 @@ webRouter.get("/forceOpen", async (request: Request, response: Response) => { const opening = formatOpening( await prisma.opening.findUnique({ where: { - id: Number.parseInt(request.query.id as string), + id: request.query.id as string, date: null, borrow: null, }, @@ -155,9 +155,7 @@ webRouter.get("/forceOpen", async (request: Request, response: Response) => { if (!opening) { return response.redirect("/"); } - const newCode = await generateNewCode( - Number.parseInt(request.query.id as string) - ); + const newCode = await generateNewCode(request.query.id as string); response.render(path.join(__dirname, "../www/getCode.html"), { code: newCode, joycons: opening.borrow.joyconsTaken,