signal-desktop/ts/sql/migrations/52-optimize-stories.ts

23 lines
674 B
TypeScript
Raw Normal View History

// Copyright 2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
2025-03-12 14:45:54 -07:00
import type { Database } from '@signalapp/sqlcipher';
2025-08-06 10:32:08 -07:00
export default function updateToSchemaVersion52(db: Database): void {
db.exec(
`
-- Create indices that don't have storyId in them so that
-- '_storyIdPredicate' could be optimized.
-- See migration 47
CREATE INDEX messages_conversation_no_story_id ON messages
(conversationId, isStory, received_at, sent_at);
-- See migration 50
CREATE INDEX messages_unread_no_story_id ON messages
(conversationId, readStatus, isStory, received_at, sent_at)
WHERE readStatus IS NOT NULL;
`
);
}