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.5 KB
Raw Blame
INSERT INTO macro_user (id, username, email, stripe_customer_id)
VALUES ('01900000-0000-7000-8000-000000000001', 'cleanup', '[email protected]', 'cleanup-stripe-id');

-- Non-user principals still need compatibility rows for the legacy owner FKs.
INSERT INTO "User" (id, email, macro_user_id)
VALUES
    ('macro|[email protected]', '[email protected]', '01900000-0000-7000-8000-000000000001'),
    ('macro|[email protected]', '[email protected]', '01900000-0000-7000-8000-000000000001'),
    ('bot|01900000-0000-7000-8000-000000000002', '[email protected]', '01900000-0000-7000-8000-000000000001'),
    ('01900000-0000-7000-8000-000000000003', '[email protected]', '01900000-0000-7000-8000-000000000001');

INSERT INTO entity (id, entity_type, owner_type, owner_id)
VALUES
    ('01900000-0000-7000-8000-000000000101', 'document', 'user', 'macro|[email protected]'),
    ('01900000-0000-7000-8000-000000000102', 'chat', 'user', 'macro|[email protected]'),
    ('01900000-0000-7000-8000-000000000103', 'project', 'user', 'macro|[email protected]'),
    ('01900000-0000-7000-8000-000000000201', 'document', 'user', 'macro|[email protected]'),
    ('01900000-0000-7000-8000-000000000202', 'chat', 'user', 'macro|[email protected]'),
    ('01900000-0000-7000-8000-000000000203', 'project', 'user', 'macro|[email protected]'),
    ('01900000-0000-7000-8000-000000000301', 'document', 'bot', 'bot|01900000-0000-7000-8000-000000000002'),
    ('01900000-0000-7000-8000-000000000302', 'chat', 'bot', 'bot|01900000-0000-7000-8000-000000000002'),
    ('01900000-0000-7000-8000-000000000303', 'project', 'bot', 'bot|01900000-0000-7000-8000-000000000002'),
    ('01900000-0000-7000-8000-000000000401', 'document', 'team', '01900000-0000-7000-8000-000000000003'),
    ('01900000-0000-7000-8000-000000000402', 'chat', 'team', '01900000-0000-7000-8000-000000000003'),
    ('01900000-0000-7000-8000-000000000403', 'project', 'team', '01900000-0000-7000-8000-000000000003');

INSERT INTO "Document" (id, name, owner, "deletedAt")
SELECT id::text, 'cleanup document', owner_id,
    CASE WHEN owner_id = 'macro|[email protected]' THEN now() END
FROM entity WHERE entity_type = 'document';

INSERT INTO "Chat" (id, name, "userId")
SELECT id::text, 'cleanup chat', owner_id FROM entity WHERE entity_type = 'chat';

INSERT INTO "Project" (id, name, "userId")
SELECT id::text, 'cleanup project', owner_id FROM entity WHERE entity_type = 'project';

-- Include a UUID document whose registry record has not been backfilled yet.
INSERT INTO "Document" (id, name, owner)
VALUES ('01900000-0000-7000-8000-000000000104', 'unregistered', 'macro|[email protected]');

-- All resources are shared with the deleted user AND another user. Cleanup must
-- remove every grant on owned resources, but not grants on non-owned resources.
INSERT INTO entity_access (entity_id, entity_type, source_id, source_type, access_level)
SELECT e.id, e.entity_type, u.id, 'user', 'view'
FROM entity e
CROSS JOIN "User" u
WHERE u.id IN ('macro|[email protected]', 'macro|[email protected]');

INSERT INTO entity_access (entity_id, entity_type, source_id, source_type, access_level)
VALUES ('01900000-0000-7000-8000-000000000104', 'document', 'macro|[email protected]', 'user', 'view');

-- The unrelated document survives, but this inherited grant must not.
INSERT INTO entity_access (entity_id, entity_type, source_id, source_type, access_level, granted_from_project_id)
VALUES ('01900000-0000-7000-8000-000000000201', 'document', 'macro|[email protected]', 'user', 'view', '01900000-0000-7000-8000-000000000103');