bliss/migrations/005_add_privacy.sql
2026-08-19 09:51:07 -04:00

15 lines
737 B
SQL

-- Private structures. A structure is public by default (private = 0); when
-- private = 1 only the users listed in structure_members may reach its routes,
-- mount its dbs, or open it in the workshop — a flat set of equals, no creator
-- or owner. Enforcement lives in the platform (index.js / plumbing.js), never in
-- user code — see canAccessStructure in db.js.
ALTER TABLE structures ADD COLUMN private INTEGER NOT NULL DEFAULT 0;
CREATE TABLE structure_members (
structure_id INTEGER NOT NULL,
user_id INTEGER NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY(structure_id, user_id),
FOREIGN KEY(structure_id) REFERENCES structures(id),
FOREIGN KEY(user_id) REFERENCES users(id)
);