Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(macro_db_client): add initiative tables (#6392)
Will Hutchinson14f33dad89ee
diff --git a/crates/macro_db_client/migrations/20260910144344_create_initiative.sql b/crates/macro_db_client/migrations/20260910144344_create_initiative.sqlnew file mode 100644index 0000000000..54d4c05d94--- /dev/null+++ b/crates/macro_db_client/migrations/20260910144344_create_initiative.sql@@ -0,0 +1,49 @@+-- Initiatives: a named grouping of tasks owned by a user, shared through one+-- SharePermission row, with optional additional members.+--+-- Ids are generated by the application as uuid v7 (macro_uuid), not by the+-- database, so they are time-ordered and known before the insert returns.+CREATE TABLE IF NOT EXISTS initiative+(+ id UUID PRIMARY KEY NOT NULL,+ name TEXT NOT NULL,+ description TEXT NOT NULL DEFAULT '',+ owner_user_id TEXT NOT NULL REFERENCES "User" (id) ON DELETE CASCADE,+ share_permission_id TEXT NOT NULL UNIQUE REFERENCES "SharePermission" (id),+ created_at TIMESTAMPTZ NOT NULL DEFAULT now(),+ updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),+ -- The DB is the final guardrail for what the service already validates, so+ -- a direct SQL path cannot leave an unusable row behind. `length()` counts+ -- characters, matching the service's char-based limit.+ CONSTRAINT initiative_name_non_empty+ CHECK (length(btrim(name)) > 0),+ CONSTRAINT initiative_name_max_length+ CHECK (length(name) <= 200),+ CONSTRAINT initiative_description_max_length+ CHECK (length(description) <= 10000)+);++CREATE INDEX IF NOT EXISTS initiative_owner_user_id_idx+ ON initiative (owner_user_id);++CREATE TABLE IF NOT EXISTS initiative_member+(+ initiative_id UUID NOT NULL REFERENCES initiative (id) ON DELETE CASCADE,+ user_id TEXT NOT NULL REFERENCES "User" (id) ON DELETE CASCADE,+ created_at TIMESTAMPTZ NOT NULL DEFAULT now(),+ PRIMARY KEY (initiative_id, user_id)+);++CREATE INDEX IF NOT EXISTS initiative_member_user_id_idx+ ON initiative_member (user_id);++-- A task belongs to at most one initiative: task_id is the primary key.+CREATE TABLE IF NOT EXISTS task_initiative+(+ task_id TEXT PRIMARY KEY NOT NULL REFERENCES "Document" (id) ON DELETE CASCADE,+ initiative_id UUID NOT NULL REFERENCES initiative (id) ON DELETE CASCADE,+ created_at TIMESTAMPTZ NOT NULL DEFAULT now()+);++CREATE INDEX IF NOT EXISTS task_initiative_initiative_id_idx+ ON task_initiative (initiative_id);