Further improvements for backup import/export

This commit is contained in:
Fedor Indutny 2024-09-18 22:26:52 -07:00 committed by GitHub
parent b9cd858ec7
commit d5f44c1b8f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 539 additions and 201 deletions

View file

@ -4181,20 +4181,24 @@ function saveCallHistory(
callId,
peerId,
ringerId,
startedById,
mode,
type,
direction,
status,
timestamp
timestamp,
endedTimestamp
) VALUES (
${callHistory.callId},
${callHistory.peerId},
${callHistory.ringerId},
${callHistory.startedById},
${callHistory.mode},
${callHistory.type},
${callHistory.direction},
${callHistory.status},
${callHistory.timestamp}
${callHistory.timestamp},
${callHistory.endedTimestamp}
);
`;

View file

@ -0,0 +1,30 @@
// Copyright 2024 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type { Database } from '@signalapp/better-sqlite3';
import type { LoggerType } from '../../types/Logging';
export const version = 1210;
export function updateToSchemaVersion1210(
currentVersion: number,
db: Database,
logger: LoggerType
): void {
if (currentVersion >= 1210) {
return;
}
db.transaction(() => {
// The standard getNextAttachmentDownloadJobs query uses active & source conditions,
// ordered by received_at
db.exec(`
ALTER TABLE callsHistory
ADD COLUMN startedById TEXT DEFAULT NULL;
ALTER TABLE callsHistory
ADD COLUMN endedTimestamp INTEGER DEFAULT NULL;
`);
db.pragma('user_version = 1210');
})();
logger.info('updateToSchemaVersion1210: success!');
}

View file

@ -171,6 +171,10 @@ function convertLegacyCallDetails(
direction,
status,
timestamp,
// Not present at the time of this migration
startedById: null,
endedTimestamp: null,
};
const result = callHistoryDetailsSchema.safeParse(callHistory);

View file

@ -96,10 +96,11 @@ import { updateToSchemaVersion1160 } from './1160-optimize-calls-unread-count';
import { updateToSchemaVersion1170 } from './1170-update-call-history-unread-index';
import { updateToSchemaVersion1180 } from './1180-add-attachment-download-source';
import { updateToSchemaVersion1190 } from './1190-call-links-storage';
import { updateToSchemaVersion1200 } from './1200-attachment-download-source-index';
import {
updateToSchemaVersion1200,
updateToSchemaVersion1210,
version as MAX_VERSION,
} from './1200-attachment-download-source-index';
} from './1210-call-history-started-id';
function updateToSchemaVersion1(
currentVersion: number,
@ -2063,7 +2064,9 @@ export const SCHEMA_VERSIONS = [
updateToSchemaVersion1170,
updateToSchemaVersion1180,
updateToSchemaVersion1190,
updateToSchemaVersion1200,
updateToSchemaVersion1210,
];
export class DBVersionFromFutureError extends Error {