New getRecentStoryReplies function to clean up replies in multiple convos
This commit is contained in:
parent
ca84d637ae
commit
716f852970
11 changed files with 356 additions and 63 deletions
32
ts/sql/migrations/86-story-replies-index.ts
Normal file
32
ts/sql/migrations/86-story-replies-index.ts
Normal file
|
@ -0,0 +1,32 @@
|
|||
// Copyright 2023 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import type { Database } from '@signalapp/better-sqlite3';
|
||||
|
||||
import type { LoggerType } from '../../types/Logging';
|
||||
|
||||
export default function updateToSchemaVersion86(
|
||||
currentVersion: number,
|
||||
db: Database,
|
||||
logger: LoggerType
|
||||
): void {
|
||||
if (currentVersion >= 86) {
|
||||
return;
|
||||
}
|
||||
|
||||
db.transaction(() => {
|
||||
// The key reason for this new schema is that all of our previous schemas start with
|
||||
// conversationId. This query is meant to find all replies to a given story, no
|
||||
// matter the conversation.
|
||||
db.exec(
|
||||
`CREATE INDEX messages_story_replies
|
||||
ON messages (storyId, received_at, sent_at)
|
||||
WHERE isStory IS 0;
|
||||
`
|
||||
);
|
||||
|
||||
db.pragma('user_version = 86');
|
||||
})();
|
||||
|
||||
logger.info('updateToSchemaVersion86: success!');
|
||||
}
|
|
@ -61,6 +61,7 @@ import updateToSchemaVersion82 from './82-edited-messages-read-index';
|
|||
import updateToSchemaVersion83 from './83-mentions';
|
||||
import updateToSchemaVersion84 from './84-all-mentions';
|
||||
import updateToSchemaVersion85 from './85-add-kyber-keys';
|
||||
import updateToSchemaVersion86 from './86-story-replies-index';
|
||||
|
||||
function updateToSchemaVersion1(
|
||||
currentVersion: number,
|
||||
|
@ -1992,6 +1993,7 @@ export const SCHEMA_VERSIONS = [
|
|||
updateToSchemaVersion83,
|
||||
updateToSchemaVersion84,
|
||||
updateToSchemaVersion85,
|
||||
updateToSchemaVersion86,
|
||||
];
|
||||
|
||||
export function updateSchema(db: Database, logger: LoggerType): void {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue