Handle missing conversation in SQL migration 41
This commit is contained in:
parent
6efb6da937
commit
fbedda194c
1 changed files with 14 additions and 12 deletions
|
@ -2113,15 +2113,17 @@ function updateToSchemaVersion41(currentVersion: number, db: Database) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const getConversationUuid = db.prepare<Query>(
|
const getConversationUuid = db
|
||||||
`
|
.prepare<Query>(
|
||||||
SELECT uuid
|
`
|
||||||
FROM
|
SELECT uuid
|
||||||
conversations
|
FROM
|
||||||
WHERE
|
conversations
|
||||||
id = $conversationId
|
WHERE
|
||||||
`
|
id = $conversationId
|
||||||
);
|
`
|
||||||
|
)
|
||||||
|
.pluck();
|
||||||
|
|
||||||
const clearSessionsAndKeys = () => {
|
const clearSessionsAndKeys = () => {
|
||||||
// ts/background.ts will ask user to relink so all that matters here is
|
// ts/background.ts will ask user to relink so all that matters here is
|
||||||
|
@ -2250,7 +2252,7 @@ function updateToSchemaVersion41(currentVersion: number, db: Database) {
|
||||||
let deleted = 0;
|
let deleted = 0;
|
||||||
for (const { id, senderId } of senderKeys) {
|
for (const { id, senderId } of senderKeys) {
|
||||||
const [conversationId] = Helpers.unencodeNumber(senderId);
|
const [conversationId] = Helpers.unencodeNumber(senderId);
|
||||||
const { uuid } = getConversationUuid.get({ conversationId });
|
const uuid = getConversationUuid.get({ conversationId });
|
||||||
|
|
||||||
if (!uuid) {
|
if (!uuid) {
|
||||||
deleted += 1;
|
deleted += 1;
|
||||||
|
@ -2311,7 +2313,7 @@ function updateToSchemaVersion41(currentVersion: number, db: Database) {
|
||||||
let updated = 0;
|
let updated = 0;
|
||||||
let deleted = 0;
|
let deleted = 0;
|
||||||
for (const { id, conversationId } of allSessions) {
|
for (const { id, conversationId } of allSessions) {
|
||||||
const { uuid } = getConversationUuid.get({ conversationId });
|
const uuid = getConversationUuid.get({ conversationId });
|
||||||
if (!uuid) {
|
if (!uuid) {
|
||||||
deleted += 1;
|
deleted += 1;
|
||||||
deleteSession.run({ id });
|
deleteSession.run({ id });
|
||||||
|
@ -2359,7 +2361,7 @@ function updateToSchemaVersion41(currentVersion: number, db: Database) {
|
||||||
|
|
||||||
let migrated = 0;
|
let migrated = 0;
|
||||||
for (const { id } of identityKeys) {
|
for (const { id } of identityKeys) {
|
||||||
const { uuid } = getConversationUuid.get({ conversationId: id });
|
const uuid = getConversationUuid.get({ conversationId: id });
|
||||||
|
|
||||||
let newId: string;
|
let newId: string;
|
||||||
if (uuid) {
|
if (uuid) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue