Fix messages_preview index
This commit is contained in:
parent
f49df88877
commit
fa8ff2ae4c
4 changed files with 68 additions and 7 deletions
33
ts/sql/migrations/49-fix-preview-index.ts
Normal file
33
ts/sql/migrations/49-fix-preview-index.ts
Normal file
|
@ -0,0 +1,33 @@
|
|||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import type { Database } from 'better-sqlite3';
|
||||
|
||||
import type { LoggerType } from '../../types/Logging';
|
||||
|
||||
export default function updateToSchemaVersion49(
|
||||
currentVersion: number,
|
||||
db: Database,
|
||||
logger: LoggerType
|
||||
): void {
|
||||
if (currentVersion >= 49) {
|
||||
return;
|
||||
}
|
||||
|
||||
db.transaction(() => {
|
||||
db.exec(
|
||||
`
|
||||
DROP INDEX messages_preview;
|
||||
|
||||
-- Note the omitted 'expiresAt' column in the index. If it is present
|
||||
-- sqlite can't ORDER BY received_at, sent_at using this index.
|
||||
CREATE INDEX messages_preview ON messages
|
||||
(conversationId, shouldAffectPreview, isGroupLeaveEventFromOther, received_at, sent_at);
|
||||
`
|
||||
);
|
||||
|
||||
db.pragma('user_version = 49');
|
||||
})();
|
||||
|
||||
logger.info('updateToSchemaVersion49: success!');
|
||||
}
|
|
@ -24,6 +24,7 @@ import updateToSchemaVersion45 from './45-stories';
|
|||
import updateToSchemaVersion46 from './46-optimize-stories';
|
||||
import updateToSchemaVersion47 from './47-further-optimize';
|
||||
import updateToSchemaVersion48 from './48-fix-user-initiated-index';
|
||||
import updateToSchemaVersion49 from './49-fix-preview-index';
|
||||
|
||||
function updateToSchemaVersion1(
|
||||
currentVersion: number,
|
||||
|
@ -1911,6 +1912,7 @@ export const SCHEMA_VERSIONS = [
|
|||
updateToSchemaVersion46,
|
||||
updateToSchemaVersion47,
|
||||
updateToSchemaVersion48,
|
||||
updateToSchemaVersion49,
|
||||
];
|
||||
|
||||
export function updateSchema(db: Database, logger: LoggerType): void {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue