Optimize FTS5
This commit is contained in:
parent
4ab950c8b2
commit
f8b936f258
2 changed files with 34 additions and 2 deletions
30
ts/sql/migrations/970-fts5-optimize.ts
Normal file
30
ts/sql/migrations/970-fts5-optimize.ts
Normal file
|
@ -0,0 +1,30 @@
|
|||
// Copyright 2023 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 = 970;
|
||||
|
||||
export function updateToSchemaVersion970(
|
||||
currentVersion: number,
|
||||
db: Database,
|
||||
logger: LoggerType
|
||||
): void {
|
||||
if (currentVersion >= 970) {
|
||||
return;
|
||||
}
|
||||
|
||||
const start = Date.now();
|
||||
db.transaction(() => {
|
||||
db.exec(`
|
||||
INSERT INTO messages_fts(messages_fts) VALUES ('optimize');
|
||||
`);
|
||||
db.pragma('user_version = 970');
|
||||
})();
|
||||
|
||||
const duration = Date.now() - start;
|
||||
logger.info(
|
||||
`updateToSchemaVersion970: success! fts optimize took ${duration}ms`
|
||||
);
|
||||
}
|
|
@ -71,10 +71,11 @@ import { updateToSchemaVersion920 } from './920-clean-more-keys';
|
|||
import { updateToSchemaVersion930 } from './930-fts5-secure-delete';
|
||||
import { updateToSchemaVersion940 } from './940-fts5-revert';
|
||||
import { updateToSchemaVersion950 } from './950-fts5-secure-delete';
|
||||
import { updateToSchemaVersion960 } from './960-untag-pni';
|
||||
import {
|
||||
version as MAX_VERSION,
|
||||
updateToSchemaVersion960,
|
||||
} from './960-untag-pni';
|
||||
updateToSchemaVersion970,
|
||||
} from './970-fts5-optimize';
|
||||
|
||||
function updateToSchemaVersion1(
|
||||
currentVersion: number,
|
||||
|
@ -2013,6 +2014,7 @@ export const SCHEMA_VERSIONS = [
|
|||
updateToSchemaVersion940,
|
||||
updateToSchemaVersion950,
|
||||
updateToSchemaVersion960,
|
||||
updateToSchemaVersion970,
|
||||
];
|
||||
|
||||
export class DBVersionFromFutureError extends Error {
|
||||
|
|
Loading…
Reference in a new issue