Introduce incrementMessagesMigrationAttempts query
Co-authored-by: trevor-signal <131492920+trevor-signal@users.noreply.github.com>
This commit is contained in:
parent
7db33a6708
commit
67252866cf
5 changed files with 113 additions and 14 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue