2022-06-03 01:09:13 +00:00
|
|
|
// Copyright 2021-2022 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2022-12-14 20:48:36 +00:00
|
|
|
import type { Database } from '@signalapp/better-sqlite3';
|
2022-06-03 01:09:13 +00:00
|
|
|
|
|
|
|
import type { LoggerType } from '../../types/Logging';
|
|
|
|
|
2022-06-10 16:09:21 +00:00
|
|
|
// TODO: DESKTOP-3694
|
|
|
|
export default function updateToSchemaVersion60(
|
2022-06-03 01:09:13 +00:00
|
|
|
currentVersion: number,
|
|
|
|
db: Database,
|
|
|
|
logger: LoggerType
|
|
|
|
): void {
|
2022-06-10 16:09:21 +00:00
|
|
|
if (currentVersion >= 60) {
|
2022-06-03 01:09:13 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
db.transaction(() => {
|
|
|
|
db.exec(
|
|
|
|
`
|
|
|
|
DROP INDEX expiring_message_by_conversation_and_received_at;
|
|
|
|
|
|
|
|
CREATE INDEX expiring_message_by_conversation_and_received_at
|
|
|
|
ON messages
|
|
|
|
(
|
|
|
|
conversationId,
|
2022-06-10 16:09:21 +00:00
|
|
|
storyId,
|
2022-06-03 01:09:13 +00:00
|
|
|
expirationStartTimestamp,
|
|
|
|
expireTimer,
|
2022-06-10 16:09:21 +00:00
|
|
|
received_at
|
2022-06-03 01:09:13 +00:00
|
|
|
)
|
|
|
|
WHERE isStory IS 0 AND type IS 'incoming';
|
|
|
|
`
|
|
|
|
);
|
|
|
|
|
2022-06-10 16:09:21 +00:00
|
|
|
db.pragma('user_version = 60');
|
2022-06-03 01:09:13 +00:00
|
|
|
})();
|
|
|
|
|
2022-06-10 16:09:21 +00:00
|
|
|
logger.info('updateToSchemaVersion60: success!');
|
2022-06-03 01:09:13 +00:00
|
|
|
}
|