Add where clause to sql migrations

This commit is contained in:
Owen
2025-09-28 10:32:46 -07:00
parent df92e41384
commit 2c8082451f
2 changed files with 6 additions and 4 deletions

View File

@@ -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}
`);
}

View File

@@ -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);
}
})();