feat(core): type definitions with an emoji icon, synced as PutTypeDef

Schema v8 adds type_defs (name, icon, tombstone, hlc). create_type,
set_type_icon, remove_type and rename_type; rename_tag moves the icon and
type_catalog lists icons and defined-but-unused types.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dasemuandClaude Opus 5.5 committed 2026-10-26 06:33:33 +01:00
1 parent a8559fd467
commit 206b62d4ab
8 files changed
+471 -16

No files matched your search

+11 -1
View File
@@ -1,6 +1,6 @@
use rusqlite::OptionalExtension;
pub const VERSION: i64 = 7;
pub const VERSION: i64 = 8;
pub const SCHEMA: &str = r#"
CREATE TABLE IF NOT EXISTS meta (key TEXT PRIMARY KEY, value TEXT NOT NULL);
@@ -107,6 +107,15 @@ CREATE TABLE IF NOT EXISTS assets (
created_at INTEGER NOT NULL
);
-- v8: type metadata (icon), one row per type name key; `removed` rows are tombstones.
CREATE TABLE IF NOT EXISTS type_defs (
type_key TEXT PRIMARY KEY,
name TEXT NOT NULL,
icon TEXT,
removed INTEGER NOT NULL DEFAULT 0,
hlc TEXT NOT NULL
);
CREATE TABLE IF NOT EXISTS tombstones (id TEXT PRIMARY KEY, hlc TEXT NOT NULL);
CREATE TABLE IF NOT EXISTS ops (
@@ -272,6 +281,7 @@ pub fn migrate(conn: &rusqlite::Connection) -> rusqlite::Result<()> {
// v7: a page's hub title is an implicit tag, so the index changes.
rebuild_page_tags(conn)?;
}
// v8: `type_defs` (type icons) is created empty by `SCHEMA`; nothing to convert.
conn.execute(
"INSERT OR REPLACE INTO meta(key, value) VALUES ('schema', ?1)",
[VERSION.to_string()],