signal-desktop/ts/sql/migrations/1310-muted-fixup.ts

28 lines
823 B
TypeScript
Raw Normal View History

// Copyright 2025 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type { LoggerType } from '../../types/Logging.js';
import { sql } from '../util.js';
import type { WritableDB } from '../Interface.js';
// Value from ts/util/timestamp.ts at the time of creation of this migration
const MAX_SAFE_DATE = 8640000000000000;
2025-08-06 10:32:08 -07:00
export default function updateToSchemaVersion1310(
db: WritableDB,
logger: LoggerType
): void {
2025-08-06 10:32:08 -07:00
const [query, params] = sql`
UPDATE conversations
SET json = json_replace(
json,
'$.muteExpiresAt',
9007199254740991 -- max safe integer
)
WHERE json ->> '$.muteExpiresAt' IS ${MAX_SAFE_DATE};
`;
const { changes } = db.prepare(query).run(params);
if (changes !== 0) {
logger.warn(`fixed ${changes} conversations`);
}
}