feat(db): add wiki-link extraction, resolution, and backlinks
CI / test (pull_request) Successful in 2m27s
CI / test (pull_request) Successful in 2m27s
[[wiki-links]] in entry bodies are extracted at save time, resolved to entity IDs (title match first, body substring fallback), and stored in entity_links junction table. Backlinks surface in TUI detail view showing entries that link to the current entry. Schema migration v5 adds entity_links with CASCADE/SET NULL semantics. Links sync on Create, Update, and Absorb.
This commit is contained in:
+15
-1
@@ -56,7 +56,7 @@ func (s *Store) Backup(dst string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
const currentSchema = 4
|
||||
const currentSchema = 5
|
||||
|
||||
var migrations = []func(db *sql.DB) error{
|
||||
// v1: initial schema
|
||||
@@ -188,6 +188,20 @@ var migrations = []func(db *sql.DB) error{
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
||||
// v5: add entity_links table for wiki-links
|
||||
func(db *sql.DB) error {
|
||||
_, err := db.Exec(`
|
||||
CREATE TABLE entity_links (
|
||||
from_id TEXT NOT NULL REFERENCES entities(id) ON DELETE CASCADE,
|
||||
to_id TEXT REFERENCES entities(id) ON DELETE SET NULL,
|
||||
link_text TEXT NOT NULL,
|
||||
PRIMARY KEY (from_id, link_text)
|
||||
);
|
||||
CREATE INDEX idx_entity_links_to ON entity_links(to_id) WHERE to_id IS NOT NULL;
|
||||
`)
|
||||
return err
|
||||
},
|
||||
}
|
||||
|
||||
func (s *Store) migrate() error {
|
||||
|
||||
Reference in New Issue
Block a user