Simplify database migrations

This commit is contained in:
Fedor Indutny 2025-08-06 10:32:08 -07:00 committed by GitHub
commit e6809c95db
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
106 changed files with 4661 additions and 6814 deletions

View file

@ -3,31 +3,15 @@
import type { Database } from '@signalapp/sqlcipher';
import type { LoggerType } from '../../types/Logging';
export default function updateToSchemaVersion49(db: Database): void {
db.exec(
`
DROP INDEX messages_preview;
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!');
-- 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);
`
);
}