Simplify database migrations
This commit is contained in:
parent
46d5b06bfc
commit
e6809c95db
106 changed files with 4661 additions and 6814 deletions
|
@ -3,42 +3,26 @@
|
|||
|
||||
import type { Database } from '@signalapp/sqlcipher';
|
||||
|
||||
import type { LoggerType } from '../../types/Logging';
|
||||
export default function updateToSchemaVersion77(db: Database): void {
|
||||
db.exec(
|
||||
`
|
||||
-- Create FTS table with custom tokenizer from
|
||||
-- @signalapp/sqlcipher.
|
||||
|
||||
export default function updateToSchemaVersion77(
|
||||
currentVersion: number,
|
||||
db: Database,
|
||||
logger: LoggerType
|
||||
): void {
|
||||
if (currentVersion >= 77) {
|
||||
return;
|
||||
}
|
||||
DROP TABLE messages_fts;
|
||||
|
||||
db.transaction(() => {
|
||||
db.exec(
|
||||
`
|
||||
-- Create FTS table with custom tokenizer from
|
||||
-- @signalapp/sqlcipher.
|
||||
|
||||
DROP TABLE messages_fts;
|
||||
|
||||
CREATE VIRTUAL TABLE messages_fts USING fts5(
|
||||
body,
|
||||
tokenize = 'signal_tokenizer'
|
||||
);
|
||||
|
||||
-- Reindex messages
|
||||
-- Based on messages_on_insert trigger from migrations/45-stories.ts
|
||||
|
||||
INSERT INTO messages_fts (rowid, body)
|
||||
SELECT rowid, body
|
||||
FROM messages
|
||||
WHERE isViewOnce IS NOT 1 AND storyId IS NULL;
|
||||
`
|
||||
CREATE VIRTUAL TABLE messages_fts USING fts5(
|
||||
body,
|
||||
tokenize = 'signal_tokenizer'
|
||||
);
|
||||
|
||||
db.pragma('user_version = 77');
|
||||
})();
|
||||
-- Reindex messages
|
||||
-- Based on messages_on_insert trigger from migrations/45-stories.ts
|
||||
|
||||
logger.info('updateToSchemaVersion77: success!');
|
||||
INSERT INTO messages_fts (rowid, body)
|
||||
SELECT rowid, body
|
||||
FROM messages
|
||||
WHERE isViewOnce IS NOT 1 AND storyId IS NULL;
|
||||
`
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue