shared: migrations: Add 2.sql: Change to contentless FTS

We never used the content copy we stored. It only wasted space.

Update scheme so we do not store the content anymore. Switch
to contentless FTS approach
This commit is contained in:
Albert S. 2022-07-28 13:44:41 +02:00
부모 7fa266e5e8
커밋 78f38fa418
2개의 변경된 파일15개의 추가작업 그리고 0개의 파일을 삭제

14
shared/migrations/2.sql Normal file
파일 보기

@ -0,0 +1,14 @@
ALTER TABLE content ADD ftsid integer;
CREATE VIRTUAL TABLE fts USING fts5(content, content='');
DROP TRIGGER contents_ai;
DROP TRIGGER contents_au;
DROP TRIGGER contents_ad;
CREATE TEMP TABLE contentstemp(id INTEGER PRIMARY KEY, content text);
CREATE TRIGGER contentstemp_ai AFTER INSERT ON contentstemp BEGIN INSERT INTO fts(content) VALUES (new.content); UPDATE content SET ftsid=last_insert_rowid() WHERE id = new.id; END;
INSERT INTO contentstemp(id, content) SELECT id, content FROM content;
DROP TRIGGER contentstemp_ai;
DROP TABLE contentstemp;
DROP TABLE content_fts;
ALTER TABLE content DROP COLUMN content;
CREATE INDEX content_ftsid ON content (ftsid);
CREATE TRIGGER content_ad AFTER DELETE ON content BEGIN INSERT INTO fts(fts, rowid) VALUES('delete', old.ftsid); END;

파일 보기

@ -1,5 +1,6 @@
<RCC>
<qresource prefix="/looqs-migrations">
<file>1.sql</file>
<file>2.sql</file>
</qresource>
</RCC>