Create wiki tables, indexes, and FTS mirrors if needed.
()
| 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 | |
| 143 | def 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 | """ |
no test coverage detected