Files
unibus/pkg/membership/migrations/001_init.sql
T

33 lines
1006 B
SQL

-- 001_init.sql — initial schema for the unibus membership/key-distribution service.
-- Additive and idempotent: safe to apply repeatedly. Never modify this file;
-- schema changes go in new numbered migrations (see .claude/rules/db_migrations.md).
CREATE TABLE IF NOT EXISTS rooms (
room_id TEXT PRIMARY KEY,
subject TEXT NOT NULL,
key_epoch INTEGER NOT NULL DEFAULT 1,
encrypt INTEGER NOT NULL,
persist INTEGER NOT NULL,
sign_msgs INTEGER NOT NULL,
owner_endpoint TEXT NOT NULL,
created_at TEXT NOT NULL
);
CREATE TABLE IF NOT EXISTS members (
room_id TEXT NOT NULL,
endpoint TEXT NOT NULL,
role TEXT NOT NULL,
joined_at TEXT NOT NULL,
sign_pub BLOB NOT NULL,
kex_pub BLOB NOT NULL,
PRIMARY KEY (room_id, endpoint)
);
CREATE TABLE IF NOT EXISTS room_keys (
room_id TEXT NOT NULL,
epoch INTEGER NOT NULL,
endpoint TEXT NOT NULL,
sealed_key BLOB NOT NULL,
PRIMARY KEY (room_id, epoch, endpoint)
);