Class: HotwireClub::MCP::Schema
- Inherits:
-
Object
- Object
- HotwireClub::MCP::Schema
- Defined in:
- lib/hotwire_club/mcp/schema.rb
Constant Summary collapse
- DB_PATH =
File.join(Dir.pwd, "db", "kb.sqlite")
Class Method Summary collapse
- .create!(db_path = DB_PATH) ⇒ Object
-
.create_chunks_table(db) ⇒ Object
Create chunks FTS5 virtual table.
-
.create_doc_tags_table(db) ⇒ Object
Create doc_tags table.
-
.create_docs_table(db) ⇒ Object
Create docs table.
-
.create_tags_table(db) ⇒ Object
Create tags table.
Class Method Details
.create!(db_path = DB_PATH) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/hotwire_club/mcp/schema.rb', line 11 def self.create!(db_path = DB_PATH) db_dir = File.dirname(db_path) FileUtils.mkdir_p(db_dir) FileUtils.rm_f(db_path) db = SQLite3::Database.new(db_path) create_docs_table(db) (db) (db) create_chunks_table(db) db.close end |
.create_chunks_table(db) ⇒ Object
Create chunks FTS5 virtual table
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/hotwire_club/mcp/schema.rb', line 69 def self.create_chunks_table(db) db.execute <<~SQL CREATE VIRTUAL TABLE chunks USING fts5( chunk_id, doc_id, title, text, category, tags, position, tokenize='porter' ) SQL end |
.create_doc_tags_table(db) ⇒ Object
Create doc_tags table
56 57 58 59 60 61 62 63 64 |
# File 'lib/hotwire_club/mcp/schema.rb', line 56 def self.(db) db.execute <<~SQL CREATE TABLE doc_tags ( doc_id TEXT, tag TEXT, PRIMARY KEY (doc_id, tag) ) SQL end |
.create_docs_table(db) ⇒ Object
Create docs table
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/hotwire_club/mcp/schema.rb', line 29 def self.create_docs_table(db) db.execute <<~SQL CREATE TABLE docs ( id TEXT PRIMARY KEY, title TEXT, category TEXT, summary TEXT, body TEXT, date TEXT ) SQL end |
.create_tags_table(db) ⇒ Object
Create tags table
45 46 47 48 49 50 51 |
# File 'lib/hotwire_club/mcp/schema.rb', line 45 def self.(db) db.execute <<~SQL CREATE TABLE tags ( name TEXT PRIMARY KEY ) SQL end |