mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-27 05:38:12 +00:00
Improve DOE behavior for poll messages
This commit is contained in:
25
ts/sql/migrations/1561-cleanup-polls.std.ts
Normal file
25
ts/sql/migrations/1561-cleanup-polls.std.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
// Copyright 2025 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import type { LoggerType } from '../../types/Logging.std.js';
|
||||
import type { WritableDB } from '../Interface.std.js';
|
||||
import { sql } from '../util.std.js';
|
||||
|
||||
// This migration was backported to earlier branches as 1541 and 1551
|
||||
export default function updateToSchemaVersion1561(
|
||||
db: WritableDB,
|
||||
logger: LoggerType
|
||||
): void {
|
||||
const [query, params] = sql`
|
||||
UPDATE messages
|
||||
SET
|
||||
json = json_remove(json, '$.poll'),
|
||||
hasUnreadPollVotes = 0
|
||||
WHERE isErased = 1 AND (
|
||||
json->'poll' IS NOT NULL OR
|
||||
hasUnreadPollVotes IS NOT 0
|
||||
)
|
||||
`;
|
||||
const result = db.prepare(query).run(params);
|
||||
logger.info(`Updated ${result.changes} poll messages`);
|
||||
}
|
||||
@@ -132,6 +132,7 @@ import updateToSchemaVersion1530 from './1530-update-expiring-index.std.js';
|
||||
import updateToSchemaVersion1540 from './1540-partial-expiring-index.std.js';
|
||||
import updateToSchemaVersion1550 from './1550-has-link-preview.std.js';
|
||||
import updateToSchemaVersion1560 from './1560-pinned-messages.std.js';
|
||||
import updateToSchemaVersion1561 from './1561-cleanup-polls.std.js';
|
||||
|
||||
import { DataWriter } from '../Server.node.js';
|
||||
|
||||
@@ -1622,6 +1623,8 @@ export const SCHEMA_VERSIONS: ReadonlyArray<SchemaUpdateType> = [
|
||||
{ version: 1540, update: updateToSchemaVersion1540 },
|
||||
{ version: 1550, update: updateToSchemaVersion1550 },
|
||||
{ version: 1560, update: updateToSchemaVersion1560 },
|
||||
// 1561, 1551, and 1541 all refer to the same migration
|
||||
{ version: 1561, update: updateToSchemaVersion1561 },
|
||||
];
|
||||
|
||||
export class DBVersionFromFutureError extends Error {
|
||||
|
||||
Reference in New Issue
Block a user