-- A user's avatar is stored as journaled objects bound by role, mirroring -- photo_objects. Keeping the binding in the ledger means garbage collection -- preserves avatar blobs while they are referenced and reclaims them once the -- avatar is replaced or removed. CREATE TABLE IF NOT EXISTS user_avatar_objects ( user_id text NOT NULL REFERENCES users(id) ON DELETE CASCADE, object_id text NOT NULL REFERENCES objects(id) ON DELETE RESTRICT, role text NOT NULL CHECK (role IN ('avatar', 'avatar_small')), PRIMARY KEY (user_id, role) ); CREATE INDEX IF NOT EXISTS user_avatar_objects_object_idx ON user_avatar_objects (object_id);