Add indices to improve messages_on_delete trigger

This commit is contained in:
trevor-signal 2024-06-28 20:47:05 -04:00 committed by GitHub
parent 189a8a0877
commit 7ef2a9155c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 198 additions and 110 deletions

View file

@ -0,0 +1,32 @@
// Copyright 2024 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type { Database } from '@signalapp/better-sqlite3';
import type { LoggerType } from '../../types/Logging';
export const version = 1090;
export function updateToSchemaVersion1090(
currentVersion: number,
db: Database,
logger: LoggerType
): void {
if (currentVersion >= 1090) {
return;
}
db.transaction(() => {
db.exec(`
CREATE INDEX reactions_messageId
ON reactions (messageId);
CREATE INDEX storyReads_storyId
ON storyReads (storyId);
`);
})();
db.pragma('user_version = 1090');
logger.info('updateToSchemaVersion1090: success!');
}