mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-25 04:36:46 +00:00
Add indexes to support messages foreign key constraints
This commit is contained in:
33
ts/sql/migrations/1120-messages-foreign-keys-indexes.ts
Normal file
33
ts/sql/migrations/1120-messages-foreign-keys-indexes.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
// 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 = 1120;
|
||||
|
||||
export function updateToSchemaVersion1120(
|
||||
currentVersion: number,
|
||||
db: Database,
|
||||
logger: LoggerType
|
||||
): void {
|
||||
if (currentVersion >= 1120) {
|
||||
return;
|
||||
}
|
||||
|
||||
db.transaction(() => {
|
||||
/** Adds indexes for all tables with foreign key relationships to messages(id) */
|
||||
db.exec(`
|
||||
CREATE INDEX edited_messages_messageId
|
||||
ON edited_messages(messageId);
|
||||
|
||||
CREATE INDEX mentions_messageId
|
||||
ON mentions(messageId);
|
||||
`);
|
||||
})();
|
||||
|
||||
db.pragma('user_version = 1120');
|
||||
|
||||
logger.info('updateToSchemaVersion1120: success!');
|
||||
}
|
||||
Reference in New Issue
Block a user