Simplify database migrations
This commit is contained in:
parent
46d5b06bfc
commit
e6809c95db
106 changed files with 4661 additions and 6814 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue