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

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