mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-24 18:38:15 +01:00
Introduce incrementMessagesMigrationAttempts query
Co-authored-by: trevor-signal <131492920+trevor-signal@users.noreply.github.com>
This commit is contained in:
@@ -445,6 +445,7 @@ export const DataWriter: ServerWritableInterface = {
|
||||
migrateConversationMessages,
|
||||
saveEditedMessage,
|
||||
saveEditedMessages,
|
||||
incrementMessagesMigrationAttempts,
|
||||
|
||||
removeSyncTaskById,
|
||||
saveSyncTasks,
|
||||
@@ -6370,6 +6371,29 @@ function getMessagesNeedingUpgrade(
|
||||
return rows.map(row => jsonToObject(row.json));
|
||||
}
|
||||
|
||||
// Exported for tests
|
||||
export function incrementMessagesMigrationAttempts(
|
||||
db: WritableDB,
|
||||
messageIds: ReadonlyArray<string>
|
||||
): void {
|
||||
batchMultiVarQuery(db, messageIds, (batch: ReadonlyArray<string>): void => {
|
||||
const idSet = sqlJoin(batch);
|
||||
const [sqlQuery, sqlParams] = sql`
|
||||
UPDATE
|
||||
messages
|
||||
SET
|
||||
json = json_set(
|
||||
json,
|
||||
'$.schemaMigrationAttempts',
|
||||
IFNULL(json -> '$.schemaMigrationAttempts', 0) + 1
|
||||
)
|
||||
WHERE
|
||||
id IN (${idSet})
|
||||
`;
|
||||
db.prepare(sqlQuery).run(sqlParams);
|
||||
});
|
||||
}
|
||||
|
||||
function getMessagesWithVisualMediaAttachments(
|
||||
db: ReadableDB,
|
||||
conversationId: string,
|
||||
|
||||
Reference in New Issue
Block a user