Clean story reply screenshot data
This commit is contained in:
parent
e5a9bf0f7c
commit
bddf1f432d
4 changed files with 155 additions and 1 deletions
45
ts/sql/migrations/90-delete-story-reply-screenshot.ts
Normal file
45
ts/sql/migrations/90-delete-story-reply-screenshot.ts
Normal file
|
@ -0,0 +1,45 @@
|
|||
// Copyright 2023 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import type { Database } from '@signalapp/better-sqlite3';
|
||||
|
||||
import type { LoggerType } from '../../types/Logging';
|
||||
import { sql } from '../util';
|
||||
|
||||
export default function updateToSchemaVersion90(
|
||||
currentVersion: number,
|
||||
db: Database,
|
||||
logger: LoggerType
|
||||
): void {
|
||||
if (currentVersion >= 90) {
|
||||
return;
|
||||
}
|
||||
|
||||
let numChanges = 0;
|
||||
db.transaction(() => {
|
||||
const [updateQuery, updateParams] = sql`
|
||||
UPDATE messages
|
||||
SET json = json_remove(json, '$.storyReplyContext.attachment.screenshotData')
|
||||
WHERE isStory = 0
|
||||
|
||||
/* we want to find all messages with a non-null storyId, but using string
|
||||
comparison (instead of a non-null check) here causes Sqlite to use the
|
||||
storyId index */
|
||||
AND storyId > '0'
|
||||
|
||||
AND json->'storyReplyContext.attachment.screenshotData' IS NOT NULL;
|
||||
`;
|
||||
|
||||
const info = db.prepare(updateQuery).run(updateParams);
|
||||
numChanges = info.changes;
|
||||
|
||||
db.pragma('user_version = 90');
|
||||
})();
|
||||
|
||||
logger.info(
|
||||
`updateToSchemaVersion90: removed screenshotData from ${numChanges} ` +
|
||||
`message${numChanges > 1 ? 's' : ''}`
|
||||
);
|
||||
|
||||
logger.info('updateToSchemaVersion90: success!');
|
||||
}
|
|
@ -64,6 +64,7 @@ import updateToSchemaVersion85 from './85-add-kyber-keys';
|
|||
import updateToSchemaVersion86 from './86-story-replies-index';
|
||||
import updateToSchemaVersion88 from './88-service-ids';
|
||||
import updateToSchemaVersion89 from './89-call-history';
|
||||
import updateToSchemaVersion90 from './90-delete-story-reply-screenshot';
|
||||
|
||||
function updateToSchemaVersion1(
|
||||
currentVersion: number,
|
||||
|
@ -1999,6 +2000,7 @@ export const SCHEMA_VERSIONS = [
|
|||
(_v: number, _i: Database, _l: LoggerType): void => undefined, // version 87 was dropped
|
||||
updateToSchemaVersion88,
|
||||
updateToSchemaVersion89,
|
||||
updateToSchemaVersion90,
|
||||
];
|
||||
|
||||
export function updateSchema(db: Database, logger: LoggerType): void {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue