Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

3.2 KB
Raw Blame
-- SQL fixture for team_access::get_user_team tests.
--
-- Covers:
--   - Each team_role (member / admin / owner)
--   - A user with no team membership
--   - A user in two teams with different roles (defensive highest-role case)
--   - A second team scoped to a different user (isolation case)

------------------------------------------------------------
-- macro_user (referenced by "User".macro_user_id)
------------------------------------------------------------

INSERT INTO macro_user (id, username, email, stripe_customer_id) VALUES
    ('00000000-0000-0000-0000-000000000a01', 'alpha_owner', '[email protected]', 'cus_alpha_owner'),
    ('00000000-0000-0000-0000-000000000a02', 'beta_owner',  '[email protected]',  'cus_beta_owner'),
    ('00000000-0000-0000-0000-000000000a03', 'member',      '[email protected]',      'cus_member'),
    ('00000000-0000-0000-0000-000000000a04', 'admin',       '[email protected]',       'cus_admin'),
    ('00000000-0000-0000-0000-000000000a05', 'owner',       '[email protected]',       'cus_owner'),
    ('00000000-0000-0000-0000-000000000a06', 'multi',       '[email protected]',       'cus_multi'),
    ('00000000-0000-0000-0000-000000000a07', 'noteam',      '[email protected]',      'cus_noteam');

------------------------------------------------------------
-- Users
------------------------------------------------------------

INSERT INTO "User" (id, email, macro_user_id) VALUES
    ('macro|[email protected]', '[email protected]', '00000000-0000-0000-0000-000000000a01'),
    ('macro|[email protected]',  '[email protected]',  '00000000-0000-0000-0000-000000000a02'),
    ('macro|[email protected]',      '[email protected]',      '00000000-0000-0000-0000-000000000a03'),
    ('macro|[email protected]',       '[email protected]',       '00000000-0000-0000-0000-000000000a04'),
    ('macro|[email protected]',       '[email protected]',       '00000000-0000-0000-0000-000000000a05'),
    ('macro|[email protected]',       '[email protected]',       '00000000-0000-0000-0000-000000000a06'),
    ('macro|[email protected]',      '[email protected]',      '00000000-0000-0000-0000-000000000a07');

------------------------------------------------------------
-- Teams
------------------------------------------------------------

INSERT INTO team (id, name, owner_id) VALUES
    ('00000000-0000-0000-0000-0000000ea001', 'Team Alpha', 'macro|[email protected]'),
    ('00000000-0000-0000-0000-0000000ea002', 'Team Beta',  'macro|[email protected]');

------------------------------------------------------------
-- Memberships
--   Team Alpha: one user per role
--   Team Beta:  one user — used to verify we return the actual team_id
--               (not just the first or default)
--
-- Note: the schema enforces UNIQUE (user_id) on team_user, so a user can only
-- belong to one team at a time.
------------------------------------------------------------

INSERT INTO team_user (user_id, team_id, team_role) VALUES
    ('macro|[email protected]', '00000000-0000-0000-0000-0000000ea001', 'member'),
    ('macro|[email protected]',  '00000000-0000-0000-0000-0000000ea001', 'admin'),
    ('macro|[email protected]',  '00000000-0000-0000-0000-0000000ea001', 'owner'),
    ('macro|[email protected]',  '00000000-0000-0000-0000-0000000ea002', 'owner');