Fix timestamp capping for storage service
Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
This commit is contained in:
parent
5fc53ee435
commit
f15d5049f8
5 changed files with 141 additions and 7 deletions
40
ts/sql/migrations/1310-muted-fixup.ts
Normal file
40
ts/sql/migrations/1310-muted-fixup.ts
Normal file
|
@ -0,0 +1,40 @@
|
|||
// Copyright 2025 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
import type { LoggerType } from '../../types/Logging';
|
||||
import { sql } from '../util';
|
||||
import type { WritableDB } from '../Interface';
|
||||
|
||||
export const version = 1310;
|
||||
|
||||
// Value from ts/util/timestamp.ts at the time of creation of this migration
|
||||
const MAX_SAFE_DATE = 8640000000000000;
|
||||
|
||||
export function updateToSchemaVersion1310(
|
||||
currentVersion: number,
|
||||
db: WritableDB,
|
||||
logger: LoggerType
|
||||
): void {
|
||||
if (currentVersion >= 1310) {
|
||||
return;
|
||||
}
|
||||
|
||||
db.transaction(() => {
|
||||
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(`updateToSchemaVersion1310: fixed ${changes} conversations`);
|
||||
}
|
||||
|
||||
db.pragma('user_version = 1310');
|
||||
})();
|
||||
|
||||
logger.info('updateToSchemaVersion1310: success!');
|
||||
}
|
|
@ -106,10 +106,11 @@ import { updateToSchemaVersion1260 } from './1260-sync-tasks-rowid';
|
|||
import { updateToSchemaVersion1270 } from './1270-normalize-messages';
|
||||
import { updateToSchemaVersion1280 } from './1280-blob-unprocessed';
|
||||
import { updateToSchemaVersion1290 } from './1290-int-unprocessed-source-device';
|
||||
import { updateToSchemaVersion1300 } from './1300-sticker-pack-refs';
|
||||
import {
|
||||
updateToSchemaVersion1300,
|
||||
updateToSchemaVersion1310,
|
||||
version as MAX_VERSION,
|
||||
} from './1300-sticker-pack-refs';
|
||||
} from './1310-muted-fixup';
|
||||
import { DataWriter } from '../Server';
|
||||
|
||||
function updateToSchemaVersion1(
|
||||
|
@ -2087,6 +2088,7 @@ export const SCHEMA_VERSIONS = [
|
|||
updateToSchemaVersion1290,
|
||||
|
||||
updateToSchemaVersion1300,
|
||||
updateToSchemaVersion1310,
|
||||
];
|
||||
|
||||
export class DBVersionFromFutureError extends Error {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue