Skip to content

Commit 3af1e0e

Browse files
Delete all before migrating
1 parent 08b7d67 commit 3af1e0e

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

server/setup/scriptsPg/1.11.0.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,11 @@ export default async function migration() {
313313
dateCreated: string;
314314
}[];
315315

316+
// Delete the old record
317+
await db.execute(sql`
318+
DELETE FROM "webauthnCredentials";
319+
`);
320+
316321
for (const webauthnCredential of webauthnCredentials) {
317322
const newCredentialId = isoBase64URL.fromBuffer(
318323
new Uint8Array(
@@ -325,12 +330,6 @@ export default async function migration() {
325330
)
326331
);
327332

328-
// Delete the old record
329-
await db.execute(sql`
330-
DELETE FROM "webauthnCredentials"
331-
WHERE "credentialId" = ${webauthnCredential.credentialId}
332-
`);
333-
334333
// Insert the updated record with converted values
335334
await db.execute(sql`
336335
INSERT INTO "webauthnCredentials" ("credentialId", "publicKey", "userId", "signCount", "transports", "name", "lastUsed", "dateCreated")

server/setup/scriptsSqlite/1.11.0.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ export default async function migration() {
269269
dateCreated: string;
270270
}[];
271271

272+
db.prepare(`DELETE FROM 'webauthnCredentials';`).run();
273+
272274
for (const webauthnCredential of webauthnCredentials) {
273275
const newCredentialId = isoBase64URL.fromBuffer(
274276
new Uint8Array(
@@ -281,11 +283,6 @@ export default async function migration() {
281283
)
282284
);
283285

284-
// Delete the old record
285-
db.prepare(
286-
`DELETE FROM 'webauthnCredentials' WHERE 'credentialId' = ?`
287-
).run(webauthnCredential.credentialId);
288-
289286
// Insert the updated record with converted values
290287
db.prepare(
291288
`INSERT INTO 'webauthnCredentials' (credentialId, publicKey, userId, signCount, transports, name, lastUsed, dateCreated) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`

0 commit comments

Comments
 (0)