signal-desktop/ts/sql/migrations/61-distribution-list-storage.ts

45 lines
1.4 KiB
TypeScript
Raw Normal View History

2022-07-01 00:52:03 +00:00
// Copyright 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-07-01 00:52:03 +00:00
import type { LoggerType } from '../../types/Logging';
export default function updateToSchemaVersion61(
currentVersion: number,
db: Database,
logger: LoggerType
): void {
if (currentVersion >= 61) {
return;
}
db.transaction(() => {
db.exec(
`
ALTER TABLE storyDistributions DROP COLUMN avatarKey;
ALTER TABLE storyDistributions DROP COLUMN avatarUrlPath;
ALTER TABLE storyDistributions ADD COLUMN deletedAtTimestamp INTEGER;
ALTER TABLE storyDistributions ADD COLUMN allowsReplies INTEGER;
ALTER TABLE storyDistributions ADD COLUMN isBlockList INTEGER;
ALTER TABLE storyDistributions ADD COLUMN storageID STRING;
ALTER TABLE storyDistributions ADD COLUMN storageVersion INTEGER;
ALTER TABLE storyDistributions ADD COLUMN storageUnknownFields BLOB;
ALTER TABLE storyDistributions ADD COLUMN storageNeedsSync INTEGER;
ALTER TABLE messages ADD COLUMN storyDistributionListId STRING;
CREATE INDEX messages_by_distribution_list
ON messages(storyDistributionListId, received_at)
WHERE storyDistributionListId IS NOT NULL;
`
);
db.pragma('user_version = 61');
})();
logger.info('updateToSchemaVersion61: success!');
}