step 2: init command + SQLite storage + migrations + config

- storage.go: DB wrapper, migration runner (in-code SQL strings)
- migrations.go: 001_init (nodes + node_meta + indexes)
- vault.go: Init() creates .verstak/ dirs, config.yml, index.db
- config.go: YAML config read/write
- util/uuid.go: UUIDv7 generator
- cmd/verstak/main.go: init --vault PATH command
- main_test.go: TestInitCreatesVault, TestInitConfigYAML

Acceptance: go build ./... pass, go test ./... pass
Init creates test-vault with .verstak/index.db + config.yml
Repeat Init is safe.
This commit is contained in:
2026-05-30 18:58:47 +08:00
parent 982f3064ac
commit b8d8427c46
11 changed files with 474 additions and 10 deletions
+24
View File
@@ -0,0 +1,24 @@
CREATE TABLE IF NOT EXISTS nodes (
id TEXT PRIMARY KEY,
parent_id TEXT NULL REFERENCES nodes(id),
type TEXT NOT NULL,
title TEXT NOT NULL,
slug TEXT NOT NULL,
path TEXT NULL,
sort_order INTEGER NOT NULL DEFAULT 0,
created_at TEXT NOT NULL,
updated_at TEXT NOT NULL,
deleted_at TEXT NULL,
revision INTEGER NOT NULL DEFAULT 1,
device_id TEXT NULL
);
CREATE TABLE IF NOT EXISTS node_meta (
node_id TEXT NOT NULL REFERENCES nodes(id),
key TEXT NOT NULL,
value TEXT NOT NULL,
PRIMARY KEY (node_id, key)
);
CREATE INDEX IF NOT EXISTS idx_nodes_parent ON nodes(parent_id);
CREATE INDEX IF NOT EXISTS idx_nodes_deleted ON nodes(deleted_at);