Added FTS5 table to schema (full-text-search)
This commit is contained in:
parent
234188c4d4
commit
fa5a4107a6
@ -98,6 +98,176 @@ CREATE INDEX "idx_messages_senderip" ON messages (sender_ip);
|
||||
CREATE INDEX "idx_messages_sendername" ON messages (sender_name);
|
||||
|
||||
|
||||
CREATE VIRTUAL TABLE messages_fts USING fts5
|
||||
(
|
||||
scn_message_id,
|
||||
sender_user_id,
|
||||
owner_user_id,
|
||||
channel_name,
|
||||
channel_id,
|
||||
sender_ip,
|
||||
sender_name,
|
||||
timestamp_real,
|
||||
timestamp_client,
|
||||
title,
|
||||
content,
|
||||
priority,
|
||||
usr_message_id,
|
||||
|
||||
tokenize = unicode61,
|
||||
content = 'messages',
|
||||
content_rowid = 'scn_message_id'
|
||||
);
|
||||
|
||||
CREATE TRIGGER articles_after_insert AFTER INSERT ON messages BEGIN
|
||||
INSERT INTO messages_fts
|
||||
(
|
||||
rowid,
|
||||
scn_message_id,
|
||||
sender_user_id,
|
||||
owner_user_id,
|
||||
channel_name,
|
||||
channel_id,
|
||||
sender_ip,
|
||||
sender_name,
|
||||
timestamp_real,
|
||||
timestamp_client,
|
||||
title,
|
||||
content,
|
||||
priority,
|
||||
usr_message_id
|
||||
) VALUES (
|
||||
new.scn_message_id,
|
||||
new.scn_message_id,
|
||||
new.sender_user_id,
|
||||
new.owner_user_id,
|
||||
new.channel_name,
|
||||
new.channel_id,
|
||||
new.sender_ip,
|
||||
new.sender_name,
|
||||
new.timestamp_real,
|
||||
new.timestamp_client,
|
||||
new.title,
|
||||
new.content,
|
||||
new.priority,
|
||||
new.usr_message_id
|
||||
);
|
||||
END;
|
||||
|
||||
CREATE TRIGGER articles_fts_after_update AFTER UPDATE ON messages BEGIN
|
||||
INSERT INTO messages_fts
|
||||
(
|
||||
messages_fts,
|
||||
rowid,
|
||||
scn_message_id,
|
||||
sender_user_id,
|
||||
owner_user_id,
|
||||
channel_name,
|
||||
channel_id,
|
||||
sender_ip,
|
||||
sender_name,
|
||||
timestamp_real,
|
||||
timestamp_client,
|
||||
title,
|
||||
content,
|
||||
priority,
|
||||
usr_message_id
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
'delete',
|
||||
old.scn_message_id,
|
||||
old.scn_message_id,
|
||||
old.sender_user_id,
|
||||
old.owner_user_id,
|
||||
old.channel_name,
|
||||
old.channel_id,
|
||||
old.sender_ip,
|
||||
old.sender_name,
|
||||
old.timestamp_real,
|
||||
old.timestamp_client,
|
||||
old.title,
|
||||
old.content,
|
||||
old.priority,
|
||||
old.usr_message_id
|
||||
);
|
||||
INSERT INTO messages_fts
|
||||
(
|
||||
rowid,
|
||||
scn_message_id,
|
||||
sender_user_id,
|
||||
owner_user_id,
|
||||
channel_name,
|
||||
channel_id,
|
||||
sender_ip,
|
||||
sender_name,
|
||||
timestamp_real,
|
||||
timestamp_client,
|
||||
title,
|
||||
content,
|
||||
priority,
|
||||
usr_message_id
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
new.scn_message_id,
|
||||
new.scn_message_id,
|
||||
new.sender_user_id,
|
||||
new.owner_user_id,
|
||||
new.channel_name,
|
||||
new.channel_id,
|
||||
new.sender_ip,
|
||||
new.sender_name,
|
||||
new.timestamp_real,
|
||||
new.timestamp_client,
|
||||
new.title,
|
||||
new.content,
|
||||
new.priority,
|
||||
new.usr_message_id
|
||||
);
|
||||
END;
|
||||
|
||||
CREATE TRIGGER articles_fts_after_delete AFTER DELETE ON messages BEGIN
|
||||
INSERT INTO messages_fts
|
||||
(
|
||||
messages_fts,
|
||||
rowid,
|
||||
scn_message_id,
|
||||
sender_user_id,
|
||||
owner_user_id,
|
||||
channel_name,
|
||||
channel_id,
|
||||
sender_ip,
|
||||
sender_name,
|
||||
timestamp_real,
|
||||
timestamp_client,
|
||||
title,
|
||||
content,
|
||||
priority,
|
||||
usr_message_id
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
'delete',
|
||||
old.scn_message_id,
|
||||
old.scn_message_id,
|
||||
old.sender_user_id,
|
||||
old.owner_user_id,
|
||||
old.channel_name,
|
||||
old.channel_id,
|
||||
old.sender_ip,
|
||||
old.sender_name,
|
||||
old.timestamp_real,
|
||||
old.timestamp_client,
|
||||
old.title,
|
||||
old.content,
|
||||
old.priority,
|
||||
old.usr_message_id
|
||||
);
|
||||
END;
|
||||
|
||||
|
||||
|
||||
CREATE TABLE deliveries
|
||||
(
|
||||
delivery_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
|
Loading…
Reference in New Issue
Block a user