signal-desktop/ts/sql/migrations/77-signal-tokenizer.ts

29 lines
688 B
TypeScript
Raw Normal View History

2023-01-26 15:53:22 -08:00
// Copyright 2023 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
2025-03-12 14:45:54 -07:00
import type { Database } from '@signalapp/sqlcipher';
2023-01-26 15:53:22 -08:00
2025-08-06 10:32:08 -07:00
export default function updateToSchemaVersion77(db: Database): void {
db.exec(
`
-- Create FTS table with custom tokenizer from
-- @signalapp/sqlcipher.
2023-01-26 15:53:22 -08:00
2025-08-06 10:32:08 -07:00
DROP TABLE messages_fts;
2023-01-26 15:53:22 -08:00
2025-08-06 10:32:08 -07:00
CREATE VIRTUAL TABLE messages_fts USING fts5(
body,
tokenize = 'signal_tokenizer'
2023-01-26 15:53:22 -08:00
);
2025-08-06 10:32:08 -07:00
-- Reindex messages
-- Based on messages_on_insert trigger from migrations/45-stories.ts
2023-01-26 15:53:22 -08:00
2025-08-06 10:32:08 -07:00
INSERT INTO messages_fts (rowid, body)
SELECT rowid, body
FROM messages
WHERE isViewOnce IS NOT 1 AND storyId IS NULL;
`
);
2023-01-26 15:53:22 -08:00
}