Create missing index for markRead
Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
This commit is contained in:
parent
601495babb
commit
f344811e64
|
@ -1913,6 +1913,28 @@ function updateToSchemaVersion34(currentVersion: number, db: Database) {
|
||||||
console.log('updateToSchemaVersion34: success!');
|
console.log('updateToSchemaVersion34: success!');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateToSchemaVersion35(currentVersion: number, db: Database) {
|
||||||
|
if (currentVersion >= 35) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
db.transaction(() => {
|
||||||
|
db.exec(`
|
||||||
|
CREATE INDEX expiring_message_by_conversation_and_received_at
|
||||||
|
ON messages
|
||||||
|
(
|
||||||
|
expirationStartTimestamp,
|
||||||
|
expireTimer,
|
||||||
|
conversationId,
|
||||||
|
received_at
|
||||||
|
);
|
||||||
|
`);
|
||||||
|
|
||||||
|
db.pragma('user_version = 35');
|
||||||
|
})();
|
||||||
|
console.log('updateToSchemaVersion35: success!');
|
||||||
|
}
|
||||||
|
|
||||||
const SCHEMA_VERSIONS = [
|
const SCHEMA_VERSIONS = [
|
||||||
updateToSchemaVersion1,
|
updateToSchemaVersion1,
|
||||||
updateToSchemaVersion2,
|
updateToSchemaVersion2,
|
||||||
|
@ -1948,6 +1970,7 @@ const SCHEMA_VERSIONS = [
|
||||||
updateToSchemaVersion32,
|
updateToSchemaVersion32,
|
||||||
updateToSchemaVersion33,
|
updateToSchemaVersion33,
|
||||||
updateToSchemaVersion34,
|
updateToSchemaVersion34,
|
||||||
|
updateToSchemaVersion35,
|
||||||
];
|
];
|
||||||
|
|
||||||
function updateSchema(db: Database): void {
|
function updateSchema(db: Database): void {
|
||||||
|
@ -3358,6 +3381,7 @@ async function getUnreadByConversationAndMarkRead(
|
||||||
db.prepare<Query>(
|
db.prepare<Query>(
|
||||||
`
|
`
|
||||||
UPDATE messages
|
UPDATE messages
|
||||||
|
INDEXED BY expiring_message_by_conversation_and_received_at
|
||||||
SET
|
SET
|
||||||
expirationStartTimestamp = $expirationStartTimestamp,
|
expirationStartTimestamp = $expirationStartTimestamp,
|
||||||
json = json_patch(json, $jsonPatch)
|
json = json_patch(json, $jsonPatch)
|
||||||
|
@ -3380,8 +3404,9 @@ async function getUnreadByConversationAndMarkRead(
|
||||||
const rows = db
|
const rows = db
|
||||||
.prepare<Query>(
|
.prepare<Query>(
|
||||||
`
|
`
|
||||||
SELECT id, json
|
SELECT id, json FROM messages
|
||||||
FROM messages WHERE
|
INDEXED BY messages_unread
|
||||||
|
WHERE
|
||||||
unread = $unread AND
|
unread = $unread AND
|
||||||
conversationId = $conversationId AND
|
conversationId = $conversationId AND
|
||||||
received_at <= $newestUnreadId
|
received_at <= $newestUnreadId
|
||||||
|
|
Loading…
Reference in a new issue