-- EdgeCrab session database schema (v6)
-- WAL mode set at connection time, not in schema SQL.

CREATE TABLE IF NOT EXISTS schema_version (
    version INTEGER NOT NULL
);

-- FTS5 virtual table for full-text search across all sessions.
-- content= syncs with the messages table via triggers below.
CREATE VIRTUAL TABLE IF NOT EXISTS messages_fts USING fts5(
    content,
    content=messages,
    content_rowid=id
);
END;
END;
    INSERT INTO messages_fts(rowid, content) VALUES (new.id, new.content);
END;
