looqs/create.sql

16 line
827 B
MySQL

CREATE TABLE file(id INTEGER PRIMARY KEY, path varchar(4096) UNIQUE, mtime integer);
CREATE TABLE content(id INTEGER PRIMARY KEY, fileid INTEGER REFERENCES file (id) ON DELETE CASCADE, page integer, content text);
2018-01-03 09:40:13 +01:00
CREATE VIRTUAL TABLE content_fts USING fts5(content, content='content', content_rowid='id');
CREATE TRIGGER contents_ai AFTER INSERT ON content BEGIN
INSERT INTO content_fts(rowid, content) VALUES (new.id, new.content);
2018-01-03 09:40:13 +01:00
END;
CREATE TRIGGER contents_ad AFTER DELETE ON content BEGIN
INSERT INTO content_fts(content_fts, rowid, content) VALUES('delete', old.id, old.content);
2018-01-03 09:40:13 +01:00
END;
CREATE TRIGGER contents_au AFTER UPDATE ON content BEGIN
INSERT INTO content_fts(content_fts, rowid, content) VALUES('delete', old.id, old.content);
INSERT INTO content_fts(rowid, content) VALUES (new.id, new.content);
2018-01-03 09:40:13 +01:00
END;