mirror of
https://github.com/PerpetualSoftware/pad.git
synced 2026-09-25 03:42:06 +00:00
520a7ca27b
Add owner_id column to workspaces table and backfill existing workspaces from membership data (TASK-410 + TASK-480). - SQLite migration 030 and Postgres migration 010 add owner_id column with indexes on (owner_id) and (owner_id, slug) - Workspace, WorkspaceCreate models updated with OwnerID field - All workspace SELECT queries include owner_id - CreateWorkspace INSERT includes owner_id - handleCreateWorkspace sets owner_id from authenticated user - backfillWorkspaceOwners extended: sets owner_id using D3 logic (earliest owner member → earliest member → first admin) - TypeScript Workspace type updated Global UNIQUE(slug) constraint preserved for now; will be replaced with UNIQUE(owner_id, slug) in TASK-412 when auth-scoped resolution needs it.
8 lines
467 B
SQL
8 lines
467 B
SQL
-- Add owner_id column to workspaces.
|
|
-- Backfilled on startup by backfillWorkspaceOwners() with the earliest owner member.
|
|
-- The global UNIQUE(slug) constraint remains until TASK-412 replaces it
|
|
-- with UNIQUE(owner_id, slug) via table recreation.
|
|
ALTER TABLE workspaces ADD COLUMN owner_id TEXT DEFAULT '';
|
|
CREATE INDEX IF NOT EXISTS idx_workspaces_owner ON workspaces(owner_id);
|
|
CREATE INDEX IF NOT EXISTS idx_workspaces_owner_slug ON workspaces(owner_id, slug);
|