Simplify database migrations

This commit is contained in:
Fedor Indutny 2025-08-06 10:32:08 -07:00 committed by GitHub
commit e6809c95db
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
106 changed files with 4661 additions and 6814 deletions

View file

@ -1,30 +1,13 @@
// Copyright 2024 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type { Database } from '@signalapp/sqlcipher';
import type { LoggerType } from '../../types/Logging';
import { sql } from '../util';
export const version = 1260;
export default function updateToSchemaVersion1260(db: Database): void {
const [query] = sql`
DROP INDEX IF EXISTS syncTasks_order;
CREATE INDEX syncTasks_delete ON syncTasks (attempts DESC);
`;
export function updateToSchemaVersion1260(
currentVersion: number,
db: Database,
logger: LoggerType
): void {
if (currentVersion >= 1260) {
return;
}
db.transaction(() => {
const [query] = sql`
DROP INDEX IF EXISTS syncTasks_order;
CREATE INDEX syncTasks_delete ON syncTasks (attempts DESC);
`;
db.exec(query);
db.pragma('user_version = 1260');
})();
logger.info('updateToSchemaVersion1260: success!');
db.exec(query);
}