From 2c8082451f947a741a1608602c37aadff9895811 Mon Sep 17 00:00:00 2001 From: Owen Date: Sun, 28 Sep 2025 10:32:46 -0700 Subject: [PATCH] Add where clause to sql migrations --- server/setup/scriptsPg/1.10.4.ts | 2 ++ server/setup/scriptsSqlite/1.10.4.ts | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/server/setup/scriptsPg/1.10.4.ts b/server/setup/scriptsPg/1.10.4.ts index 311e6dc2..fa4ff401 100644 --- a/server/setup/scriptsPg/1.10.4.ts +++ b/server/setup/scriptsPg/1.10.4.ts @@ -18,11 +18,13 @@ export default async function migration() { const credentialId = isoBase64URL.fromBuffer(new Uint8Array(Buffer.from(webauthnCredential.credentialId, 'base64'))); await db.execute(sql` UPDATE "webauthnCredentials" SET "credentialId" = ${credentialId} + WHERE "credentialId" = ${webauthnCredential.credentialId} `); const publicKey = isoBase64URL.fromBuffer(new Uint8Array(Buffer.from(webauthnCredential.publicKey, 'base64'))); await db.execute(sql` UPDATE "webauthnCredentials" SET "publicKey" = ${publicKey} + WHERE "credentialId" = ${webauthnCredential.credentialId} `); } diff --git a/server/setup/scriptsSqlite/1.10.4.ts b/server/setup/scriptsSqlite/1.10.4.ts index 5c7f0a0e..ff22d70f 100644 --- a/server/setup/scriptsSqlite/1.10.4.ts +++ b/server/setup/scriptsSqlite/1.10.4.ts @@ -20,13 +20,13 @@ export default async function migration() { for (const webauthnCredential of webauthnCredentials) { const credentialId = isoBase64URL.fromBuffer(new Uint8Array(Buffer.from(webauthnCredential.credentialId, 'base64'))); db.prepare( - `UPDATE 'webauthnCredentials' SET 'credentialId' = ?` - ).run(credentialId); + `UPDATE 'webauthnCredentials' SET 'credentialId' = ? WHERE 'credentialId' = ?` + ).run(credentialId, webauthnCredential.credentialId); const publicKey = isoBase64URL.fromBuffer(new Uint8Array(Buffer.from(webauthnCredential.publicKey, 'base64'))); db.prepare( - `UPDATE 'webauthnCredentials' SET 'publicKey' = ?` - ).run(publicKey); + `UPDATE 'webauthnCredentials' SET 'publicKey' = ? WHERE 'credentialId' = ?` + ).run(publicKey, webauthnCredential.credentialId); } })();