Reenable FTS optimization
This commit is contained in:
parent
372d9c2198
commit
b6ed789197
10 changed files with 195 additions and 8 deletions
|
@ -17,12 +17,8 @@ export function updateToSchemaVersion930(
|
|||
}
|
||||
|
||||
db.transaction(() => {
|
||||
db.exec(`
|
||||
INSERT INTO messages_fts
|
||||
(messages_fts, rank)
|
||||
VALUES
|
||||
('secure-delete', 1);
|
||||
`);
|
||||
// This was a migration that enabled 'secure-delete' in FTS
|
||||
|
||||
db.pragma('user_version = 930');
|
||||
})();
|
||||
|
||||
|
|
55
ts/sql/migrations/940-fts5-revert.ts
Normal file
55
ts/sql/migrations/940-fts5-revert.ts
Normal file
|
@ -0,0 +1,55 @@
|
|||
// 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 = 940;
|
||||
|
||||
export function updateToSchemaVersion940(
|
||||
currentVersion: number,
|
||||
db: Database,
|
||||
logger: LoggerType
|
||||
): void {
|
||||
if (currentVersion >= 940) {
|
||||
return;
|
||||
}
|
||||
|
||||
db.transaction(() => {
|
||||
const wasEnabled =
|
||||
db
|
||||
.prepare(
|
||||
`
|
||||
SELECT v FROM messages_fts_config WHERE k is 'secure-delete';
|
||||
`
|
||||
)
|
||||
.pluck()
|
||||
.get() === 1;
|
||||
|
||||
if (wasEnabled) {
|
||||
logger.info('updateToSchemaVersion940: rebuilding fts5 index');
|
||||
db.exec(`
|
||||
--- Disable 'secure-delete'
|
||||
INSERT INTO messages_fts
|
||||
(messages_fts, rank)
|
||||
VALUES
|
||||
('secure-delete', 0);
|
||||
|
||||
--- Rebuild the index to fix the corruption
|
||||
INSERT INTO messages_fts
|
||||
(messages_fts)
|
||||
VALUES
|
||||
('rebuild');
|
||||
`);
|
||||
} else {
|
||||
logger.info(
|
||||
'updateToSchemaVersion940: secure delete was not enabled, skipping'
|
||||
);
|
||||
}
|
||||
|
||||
db.pragma('user_version = 940');
|
||||
})();
|
||||
|
||||
logger.info('updateToSchemaVersion940: success!');
|
||||
}
|
|
@ -67,10 +67,11 @@ import updateToSchemaVersion89 from './89-call-history';
|
|||
import updateToSchemaVersion90 from './90-delete-story-reply-screenshot';
|
||||
import updateToSchemaVersion91 from './91-clean-keys';
|
||||
import { updateToSchemaVersion920 } from './920-clean-more-keys';
|
||||
import { updateToSchemaVersion930 } from './930-fts5-secure-delete';
|
||||
import {
|
||||
version as MAX_VERSION,
|
||||
updateToSchemaVersion930,
|
||||
} from './930-fts5-secure-delete';
|
||||
updateToSchemaVersion940,
|
||||
} from './940-fts5-revert';
|
||||
|
||||
function updateToSchemaVersion1(
|
||||
currentVersion: number,
|
||||
|
@ -2012,6 +2013,7 @@ export const SCHEMA_VERSIONS = [
|
|||
// From here forward, all migrations should be multiples of 10
|
||||
updateToSchemaVersion920,
|
||||
updateToSchemaVersion930,
|
||||
updateToSchemaVersion940,
|
||||
];
|
||||
|
||||
export function updateSchema(db: Database, logger: LoggerType): void {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue