MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / init_wiki_schema

Function init_wiki_schema

skills/wiki-store/scripts/wiki_db.py:135–253  ·  view source on GitHub ↗

Create wiki tables, indexes, and FTS mirrors if needed.

()

Source from the content-addressed store, hash-verified

133 part
134 for part in (
135 str(node.get("title") or ""),
136 str(node.get("keywords") or ""),
137 str(node.get("body") or "")[:4000],
138 )
139 if part.strip()
140 )
141
142
143def init_wiki_schema() -> None:
144 """Create wiki tables, indexes, and FTS mirrors if needed."""
145 conn = db_ops.get_connection()
146 cursor = conn.cursor()
147
148 cursor.execute(
149 """
150 CREATE TABLE IF NOT EXISTS wiki_nodes (
151 id INTEGER PRIMARY KEY AUTOINCREMENT,
152 node_id TEXT NOT NULL,
153 user_id TEXT NOT NULL,
154 node_type TEXT NOT NULL
155 CHECK (node_type IN ('paper','section','trajectory','topic')),
156 title TEXT NOT NULL,
157 body TEXT NOT NULL,
158 metadata_json TEXT,
159 embedding BLOB,
160 embedding_model TEXT,
161 keywords TEXT,
162 file_path TEXT,
163 source_type TEXT,
164 source_ref TEXT,
165 created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
166 updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
167 UNIQUE(user_id, node_id)
168 )
169 """
170 )
171 cursor.execute(
172 """
173 CREATE TABLE IF NOT EXISTS wiki_edges (
174 id INTEGER PRIMARY KEY AUTOINCREMENT,
175 user_id TEXT NOT NULL,
176 src_id TEXT NOT NULL,
177 dst_id TEXT NOT NULL,
178 relation TEXT NOT NULL
179 CHECK (relation IN (
180 'cites','same_topic','interested_in','skipped','read',
181 'pinned_must_read','drifted_from','drifted_to',
182 'derived_from','belongs_to','contains_section'
183 )),
184 weight REAL DEFAULT 1.0,
185 metadata_json TEXT,
186 created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
187 UNIQUE(user_id, src_id, dst_id, relation)
188 )
189 """
190 )
191 cursor.execute(
192 """

Callers 11

upsert_nodeFunction · 0.85
embed_nodes_for_userFunction · 0.85
upsert_edgeFunction · 0.85
upsert_citationFunction · 0.85
get_citations_for_nodesFunction · 0.85
list_nodesFunction · 0.85
get_nodeFunction · 0.85
vector_search_nodesFunction · 0.85
search_nodesFunction · 0.85
all_user_idsFunction · 0.85
statsFunction · 0.85

Calls 4

_wiki_rootFunction · 0.85
cursorMethod · 0.80
executeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected