dnote/pkg/server/database/migrations/100-create-fts-table.sql
Sung 61162e2add
Use SQLite on the server (#681)
* Use SQLite on server

* Remove pro

* Simplify

* Use flag

* Automate release
2025-10-05 17:02:30 -07:00

18 lines
No EOL
807 B
SQL

-- Create FTS5 virtual table for full-text search on notes
CREATE VIRTUAL TABLE IF NOT EXISTS notes_fts USING fts5(
content=notes,
body,
tokenize="porter unicode61 categories 'L* N* Co Ps Pe'"
);
-- Create triggers to keep notes_fts in sync with notes
CREATE TRIGGER IF NOT EXISTS notes_insert AFTER INSERT ON notes BEGIN
INSERT INTO notes_fts(rowid, body) VALUES (new.rowid, new.body);
END;
CREATE TRIGGER IF NOT EXISTS notes_delete AFTER DELETE ON notes BEGIN
INSERT INTO notes_fts(notes_fts, rowid, body) VALUES ('delete', old.rowid, old.body);
END;
CREATE TRIGGER IF NOT EXISTS notes_update AFTER UPDATE ON notes BEGIN
INSERT INTO notes_fts(notes_fts, rowid, body) VALUES ('delete', old.rowid, old.body);
INSERT INTO notes_fts(rowid, body) VALUES (new.rowid, new.body);
END;