Increment and store message migration attempts
This commit is contained in:
parent
d547ef362e
commit
63679f5af6
4 changed files with 67 additions and 20 deletions
|
@ -4387,22 +4387,31 @@ async function removeAllConfiguration(
|
|||
})();
|
||||
}
|
||||
|
||||
const MAX_MESSAGE_MIGRATION_ATTEMPTS = 5;
|
||||
|
||||
async function getMessagesNeedingUpgrade(
|
||||
limit: number,
|
||||
{ maxVersion }: { maxVersion: number }
|
||||
): Promise<Array<MessageType>> {
|
||||
const db = getInstance();
|
||||
|
||||
const rows: JSONRows = db
|
||||
.prepare<Query>(
|
||||
`
|
||||
SELECT json
|
||||
FROM messages
|
||||
WHERE schemaVersion IS NULL OR schemaVersion < $maxVersion
|
||||
WHERE
|
||||
(schemaVersion IS NULL OR schemaVersion < $maxVersion) AND
|
||||
IFNULL(
|
||||
json_extract(json, '$.schemaMigrationAttempts'),
|
||||
0
|
||||
) < $maxAttempts
|
||||
LIMIT $limit;
|
||||
`
|
||||
)
|
||||
.all({
|
||||
maxVersion,
|
||||
maxAttempts: MAX_MESSAGE_MIGRATION_ATTEMPTS,
|
||||
limit,
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue