From e5a436593fd8955d26f0a06f297f68cc9eea9659 Mon Sep 17 00:00:00 2001 From: Owen Date: Fri, 17 Oct 2025 11:56:19 -0700 Subject: [PATCH] Delete all before migrating --- server/setup/scriptsPg/1.11.0.ts | 11 +++++------ server/setup/scriptsSqlite/1.11.0.ts | 7 ++----- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/server/setup/scriptsPg/1.11.0.ts b/server/setup/scriptsPg/1.11.0.ts index 13186b4f..4804d7e2 100644 --- a/server/setup/scriptsPg/1.11.0.ts +++ b/server/setup/scriptsPg/1.11.0.ts @@ -313,6 +313,11 @@ export default async function migration() { dateCreated: string; }[]; + // Delete the old record + await db.execute(sql` + DELETE FROM "webauthnCredentials"; + `); + for (const webauthnCredential of webauthnCredentials) { const newCredentialId = isoBase64URL.fromBuffer( new Uint8Array( @@ -325,12 +330,6 @@ export default async function migration() { ) ); - // Delete the old record - await db.execute(sql` - DELETE FROM "webauthnCredentials" - WHERE "credentialId" = ${webauthnCredential.credentialId} - `); - // Insert the updated record with converted values await db.execute(sql` INSERT INTO "webauthnCredentials" ("credentialId", "publicKey", "userId", "signCount", "transports", "name", "lastUsed", "dateCreated") diff --git a/server/setup/scriptsSqlite/1.11.0.ts b/server/setup/scriptsSqlite/1.11.0.ts index 1247eee9..c79cfdb4 100644 --- a/server/setup/scriptsSqlite/1.11.0.ts +++ b/server/setup/scriptsSqlite/1.11.0.ts @@ -269,6 +269,8 @@ export default async function migration() { dateCreated: string; }[]; + db.prepare(`DELETE FROM 'webauthnCredentials';`).run(); + for (const webauthnCredential of webauthnCredentials) { const newCredentialId = isoBase64URL.fromBuffer( new Uint8Array( @@ -281,11 +283,6 @@ export default async function migration() { ) ); - // Delete the old record - db.prepare( - `DELETE FROM 'webauthnCredentials' WHERE 'credentialId' = ?` - ).run(webauthnCredential.credentialId); - // Insert the updated record with converted values db.prepare( `INSERT INTO 'webauthnCredentials' (credentialId, publicKey, userId, signCount, transports, name, lastUsed, dateCreated) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`