mirror of
https://github.com/PerpetualSoftware/pad.git
synced 2026-09-23 19:06:33 +00:00
d74431fbb3
Add per-member collection visibility controls and mark conventions/
playbooks as system collections (TASK-413 + TASK-415).
Data model:
- workspace_members: new collection_access column ('all' or 'specific')
- New member_collection_access table (workspace_id, user_id, collection_id)
- collections: new is_system column, set for conventions and playbooks
Store methods:
- VisibleCollectionIDs(workspaceID, userID) — returns nil for "all"
access, or specific IDs (including system collections) for "specific"
- SetMemberCollectionAccess/GetMemberCollectionAccess for CRUD
- All collection queries include is_system in SELECT/scan
- Export/import handles is_system field
Default collection definitions:
- conventionsCollection and playbooksCollection set IsSystem=true
- New workspaces get system flag on seed
D7: default collection_access is "all" — absence of restrictions
means full access. System collections always visible to members.
23 lines
1.1 KiB
SQL
23 lines
1.1 KiB
SQL
-- Add per-member collection visibility.
|
|
-- collection_access: 'all' (default) = see everything, 'specific' = see only granted collections.
|
|
-- Decision D7: default is "all" — absence of restrictions means full access.
|
|
|
|
ALTER TABLE workspace_members ADD COLUMN collection_access TEXT NOT NULL DEFAULT 'all';
|
|
|
|
-- Join table for the "specific" case: which collections a member can see.
|
|
CREATE TABLE IF NOT EXISTS member_collection_access (
|
|
workspace_id TEXT NOT NULL,
|
|
user_id TEXT NOT NULL,
|
|
collection_id TEXT NOT NULL REFERENCES collections(id) ON DELETE CASCADE,
|
|
created_at TEXT NOT NULL,
|
|
PRIMARY KEY (workspace_id, user_id, collection_id),
|
|
FOREIGN KEY (workspace_id, user_id) REFERENCES workspace_members(workspace_id, user_id) ON DELETE CASCADE
|
|
);
|
|
|
|
-- Add is_system flag to collections for conventions/playbooks exemption.
|
|
-- System collections are always visible to members regardless of collection_access.
|
|
ALTER TABLE collections ADD COLUMN is_system INTEGER NOT NULL DEFAULT 0;
|
|
|
|
-- Mark conventions and playbooks as system collections.
|
|
UPDATE collections SET is_system = 1 WHERE slug IN ('conventions', 'playbooks');
|