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.

remove nullable macro_user_id (#1988)

Will Hutchinsondad904e87494
diff --git a/rust/cloud-storage/document_cognition_service/fixtures/chat_example.sql b/rust/cloud-storage/document_cognition_service/fixtures/chat_example.sql
index bbd2a92394..99de656aa7 100644
--- a/rust/cloud-storage/document_cognition_service/fixtures/chat_example.sql
+++ b/rust/cloud-storage/document_cognition_service/fixtures/chat_example.sql
@@ -1,5 +1,8 @@
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-VALUES ('macro|[email protected]', '[email protected]','stripe_id');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', 'user', '[email protected]', 'stripe_id');
+
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+VALUES ('macro|[email protected]', '[email protected]','stripe_id','a1111111-1111-1111-1111-111111111111');
-- Test Documents
INSERT INTO public."Document" ("id","name","fileType", "owner")
diff --git a/rust/cloud-storage/document_text_extractor/fixtures/basic_user_with_documents.sql b/rust/cloud-storage/document_text_extractor/fixtures/basic_user_with_documents.sql
index 175b87544a..04f92f60e6 100644
--- a/rust/cloud-storage/document_text_extractor/fixtures/basic_user_with_documents.sql
+++ b/rust/cloud-storage/document_text_extractor/fixtures/basic_user_with_documents.sql
@@ -1,5 +1,8 @@
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+(SELECT 'a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_id');
+
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id', 'a1111111-1111-1111-1111-111111111111');
INSERT INTO public."Document" ("id","name","fileType", "owner")
(SELECT 'document-one', 'test_document_name','pdf', 'macro|[email protected]');
diff --git a/rust/cloud-storage/document_text_extractor/migrations/20240325143515_basic_schema_for_testing.sql b/rust/cloud-storage/document_text_extractor/migrations/20240325143515_basic_schema_for_testing.sql
index c48b817971..a6e2a7b9bd 100644
--- a/rust/cloud-storage/document_text_extractor/migrations/20240325143515_basic_schema_for_testing.sql
+++ b/rust/cloud-storage/document_text_extractor/migrations/20240325143515_basic_schema_for_testing.sql
@@ -3,11 +3,20 @@
-- Changes here WILL NOT ever make it into the dev/production db.
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
+CREATE TABLE "macro_user" (
+ "id" UUID PRIMARY KEY,
+ "username" TEXT UNIQUE NOT NULL,
+ "email" TEXT UNIQUE NOT NULL,
+ "stripe_customer_id" TEXT UNIQUE NOT NULL
+);
+
CREATE TABLE "User" (
"id" TEXT PRIMARY KEY,
"email" TEXT UNIQUE NOT NULL,
"name" TEXT,
- "stripeCustomerId" TEXT UNIQUE
+ "stripeCustomerId" TEXT UNIQUE,
+ "macro_user_id" UUID NOT NULL,
+ FOREIGN KEY ("macro_user_id") REFERENCES "macro_user"("id")
);
CREATE TABLE "Permission" (
diff --git a/rust/cloud-storage/documents/.sqlx/query-37b5168f739c490a3373c65eab35f247a34af0a8e659cbad61cb99e3094e5a60.json b/rust/cloud-storage/documents/.sqlx/query-37b5168f739c490a3373c65eab35f247a34af0a8e659cbad61cb99e3094e5a60.json
new file mode 100644
index 0000000000..44d3a67e72
--- /dev/null
+++ b/rust/cloud-storage/documents/.sqlx/query-37b5168f739c490a3373c65eab35f247a34af0a8e659cbad61cb99e3094e5a60.json
@@ -0,0 +1,23 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT EXISTS (\n SELECT 1\n FROM public.email_threads t\n JOIN public.email_links l ON l.id = t.link_id\n WHERE t.id = $1::uuid\n AND l.macro_id = $2\n ) AS \"exists!\"\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "exists!",
+ "type_info": "Bool"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Uuid",
+ "Text"
+ ]
+ },
+ "nullable": [
+ null
+ ]
+ },
+ "hash": "37b5168f739c490a3373c65eab35f247a34af0a8e659cbad61cb99e3094e5a60"
+}
diff --git a/rust/cloud-storage/documents/.sqlx/query-3a7be99469ed150e0506efa786b672198a6d3419c6bd5548418520cd3e6a8e95.json b/rust/cloud-storage/documents/.sqlx/query-3a7be99469ed150e0506efa786b672198a6d3419c6bd5548418520cd3e6a8e95.json
new file mode 100644
index 0000000000..60bfee0647
--- /dev/null
+++ b/rust/cloud-storage/documents/.sqlx/query-3a7be99469ed150e0506efa786b672198a6d3419c6bd5548418520cd3e6a8e95.json
@@ -0,0 +1,23 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n WITH RECURSIVE project_hierarchy AS (\n SELECT p.id as project_id\n FROM \"Document\" d\n JOIN \"Project\" p ON d.\"projectId\" = p.id AND p.\"deletedAt\" IS NULL\n WHERE d.id = $1 AND d.\"deletedAt\" IS NULL\n UNION ALL\n SELECT parent.id as project_id\n FROM project_hierarchy ph\n JOIN \"Project\" parent ON parent.id = (\n SELECT \"parentId\" FROM \"Project\" WHERE id = ph.project_id AND \"parentId\" IS NOT NULL AND \"deletedAt\" IS NULL\n )\n )\n SELECT access_level FROM (\n -- Source 1: Cast the AccessLevel enum to text.\n SELECT access_level::text FROM \"UserItemAccess\"\n WHERE user_id = $2 AND item_id IN (\n SELECT $1\n UNION\n SELECT project_id FROM project_hierarchy\n )\n UNION ALL\n -- Source 2: Select the publicAccessLevel (which is already text).\n SELECT \"publicAccessLevel\" as access_level\n FROM \"SharePermission\"\n WHERE \"isPublic\" = true AND \"publicAccessLevel\" IS NOT NULL AND id IN (\n SELECT \"sharePermissionId\" FROM \"DocumentPermission\" WHERE \"documentId\" = $1\n UNION\n SELECT \"sharePermissionId\" FROM \"ProjectPermission\" WHERE \"projectId\" IN (SELECT project_id FROM project_hierarchy)\n )\n ) as all_levels\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "access_level",
+ "type_info": "Text"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Text",
+ "Text"
+ ]
+ },
+ "nullable": [
+ null
+ ]
+ },
+ "hash": "3a7be99469ed150e0506efa786b672198a6d3419c6bd5548418520cd3e6a8e95"
+}
diff --git a/rust/cloud-storage/documents/.sqlx/query-4afa79ca95bdbcebe9d3de7ebb204636419e6cf89e650a8716c40ab2e588aa5b.json b/rust/cloud-storage/documents/.sqlx/query-4afa79ca95bdbcebe9d3de7ebb204636419e6cf89e650a8716c40ab2e588aa5b.json
new file mode 100644
index 0000000000..58618b2697
--- /dev/null
+++ b/rust/cloud-storage/documents/.sqlx/query-4afa79ca95bdbcebe9d3de7ebb204636419e6cf89e650a8716c40ab2e588aa5b.json
@@ -0,0 +1,23 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n -- CTE to recursively find all parent projects, starting from the given project.\n WITH RECURSIVE project_hierarchy AS (\n -- Base case: Start with the project ID provided.\n SELECT id as project_id\n FROM \"Project\"\n WHERE id = $1 AND \"deletedAt\" IS NULL\n UNION ALL\n -- Recursive case: Find the parent of the project from the previous step.\n SELECT parent.id as project_id\n FROM project_hierarchy ph\n JOIN \"Project\" parent ON parent.id = (\n SELECT \"parentId\" FROM \"Project\" WHERE id = ph.project_id AND \"parentId\" IS NOT NULL AND \"deletedAt\" IS NULL\n )\n )\n -- The subquery now gathers all levels as plain text.\n SELECT access_level FROM (\n -- Source 1: Cast the AccessLevel enum to text.\n SELECT access_level::text FROM \"UserItemAccess\"\n WHERE user_id = $2 AND item_id IN (\n -- The hierarchy CTE includes the starting project, so this is all we need.\n SELECT project_id FROM project_hierarchy\n )\n UNION ALL\n -- Source 2: Select the publicAccessLevel (which is already text).\n SELECT \"publicAccessLevel\" as access_level\n FROM \"SharePermission\"\n WHERE \"isPublic\" = true AND \"publicAccessLevel\" IS NOT NULL AND id IN (\n -- We only need to check ProjectPermission for the items in the hierarchy.\n SELECT \"sharePermissionId\" FROM \"ProjectPermission\"\n WHERE \"projectId\" IN (SELECT project_id FROM project_hierarchy)\n )\n ) as all_levels\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "access_level",
+ "type_info": "Text"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Text",
+ "Text"
+ ]
+ },
+ "nullable": [
+ null
+ ]
+ },
+ "hash": "4afa79ca95bdbcebe9d3de7ebb204636419e6cf89e650a8716c40ab2e588aa5b"
+}
diff --git a/rust/cloud-storage/documents/.sqlx/query-4c695b011d49ba7d5fce4b309875ed952dc386ac760444d7883c5a76718f15be.json b/rust/cloud-storage/documents/.sqlx/query-4c695b011d49ba7d5fce4b309875ed952dc386ac760444d7883c5a76718f15be.json
new file mode 100644
index 0000000000..524cc25ec7
--- /dev/null
+++ b/rust/cloud-storage/documents/.sqlx/query-4c695b011d49ba7d5fce4b309875ed952dc386ac760444d7883c5a76718f15be.json
@@ -0,0 +1,23 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n WITH RECURSIVE project_hierarchy AS (\n SELECT p.id as project_id\n FROM \"Chat\" c\n JOIN \"Project\" p ON c.\"projectId\" = p.id AND p.\"deletedAt\" IS NULL\n WHERE c.id = $1 AND c.\"deletedAt\" IS NULL\n UNION ALL\n SELECT parent.id as project_id\n FROM project_hierarchy ph\n JOIN \"Project\" parent ON parent.id = (\n SELECT \"parentId\" FROM \"Project\" WHERE id = ph.project_id AND \"parentId\" IS NOT NULL AND \"deletedAt\" IS NULL\n )\n )\n SELECT access_level FROM (\n -- Source 1: Cast the AccessLevel enum to text.\n SELECT access_level::text FROM \"UserItemAccess\"\n WHERE user_id = $2 AND item_id IN (\n SELECT $1 -- The chat itself\n UNION\n SELECT project_id FROM project_hierarchy -- All parent projects\n )\n UNION ALL\n -- Source 2: Select the publicAccessLevel (which is already text).\n SELECT \"publicAccessLevel\" as access_level\n FROM \"SharePermission\"\n WHERE \"isPublic\" = true AND \"publicAccessLevel\" IS NOT NULL AND id IN (\n SELECT \"sharePermissionId\" FROM \"ChatPermission\" WHERE \"chatId\" = $1\n UNION\n SELECT \"sharePermissionId\" FROM \"ProjectPermission\" WHERE \"projectId\" IN (SELECT project_id FROM project_hierarchy)\n )\n ) as all_levels\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "access_level",
+ "type_info": "Text"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Text",
+ "Text"
+ ]
+ },
+ "nullable": [
+ null
+ ]
+ },
+ "hash": "4c695b011d49ba7d5fce4b309875ed952dc386ac760444d7883c5a76718f15be"
+}
diff --git a/rust/cloud-storage/documents/.sqlx/query-54e3755d63a676a7fa70da77321e618032f0130c73eb6b0ae985f07c5c6c448b.json b/rust/cloud-storage/documents/.sqlx/query-54e3755d63a676a7fa70da77321e618032f0130c73eb6b0ae985f07c5c6c448b.json
new file mode 100644
index 0000000000..03a8dbf6bb
--- /dev/null
+++ b/rust/cloud-storage/documents/.sqlx/query-54e3755d63a676a7fa70da77321e618032f0130c73eb6b0ae985f07c5c6c448b.json
@@ -0,0 +1,22 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n WITH RECURSIVE project_hierarchy AS (\n SELECT p.id as project_id\n FROM \"Chat\" c\n JOIN \"Project\" p ON c.\"projectId\" = p.id AND p.\"deletedAt\" IS NULL\n WHERE c.id = $1 AND c.\"deletedAt\" IS NULL\n UNION ALL\n SELECT parent.id as project_id\n FROM project_hierarchy ph\n JOIN \"Project\" parent ON parent.id = (\n SELECT \"parentId\" FROM \"Project\" WHERE id = ph.project_id AND \"parentId\" IS NOT NULL AND \"deletedAt\" IS NULL\n )\n )\n SELECT DISTINCT user_id FROM \"UserItemAccess\"\n WHERE item_id IN (\n SELECT $1\n UNION\n SELECT project_id FROM project_hierarchy\n )\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "user_id",
+ "type_info": "Text"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Text"
+ ]
+ },
+ "nullable": [
+ false
+ ]
+ },
+ "hash": "54e3755d63a676a7fa70da77321e618032f0130c73eb6b0ae985f07c5c6c448b"
+}
diff --git a/rust/cloud-storage/documents/.sqlx/query-7617f808df94ffe77c8195a911ee6b230a21fe9935e099d1310d244248ca253a.json b/rust/cloud-storage/documents/.sqlx/query-7617f808df94ffe77c8195a911ee6b230a21fe9935e099d1310d244248ca253a.json
new file mode 100644
index 0000000000..655495fb29
--- /dev/null
+++ b/rust/cloud-storage/documents/.sqlx/query-7617f808df94ffe77c8195a911ee6b230a21fe9935e099d1310d244248ca253a.json
@@ -0,0 +1,23 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT c.id\n FROM comms_channels c\n INNER JOIN comms_channel_participants cp ON cp.channel_id = c.id\n WHERE cp.user_id = $1 AND cp.left_at IS NULL\n AND c.id = ANY($2::uuid[])\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "id",
+ "type_info": "Uuid"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Text",
+ "UuidArray"
+ ]
+ },
+ "nullable": [
+ false
+ ]
+ },
+ "hash": "7617f808df94ffe77c8195a911ee6b230a21fe9935e099d1310d244248ca253a"
+}
diff --git a/rust/cloud-storage/documents/.sqlx/query-79d3bc72e6f424765706f7deea426379ae49cbd70dd122daedd95343618b9ac6.json b/rust/cloud-storage/documents/.sqlx/query-79d3bc72e6f424765706f7deea426379ae49cbd70dd122daedd95343618b9ac6.json
new file mode 100644
index 0000000000..2bde15938f
--- /dev/null
+++ b/rust/cloud-storage/documents/.sqlx/query-79d3bc72e6f424765706f7deea426379ae49cbd70dd122daedd95343618b9ac6.json
@@ -0,0 +1,22 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n WITH RECURSIVE project_hierarchy AS (\n SELECT id as project_id\n FROM \"Project\"\n WHERE id = $1 AND \"deletedAt\" IS NULL\n UNION ALL\n SELECT parent.id as project_id\n FROM project_hierarchy ph\n JOIN \"Project\" parent ON parent.id = (\n SELECT \"parentId\" FROM \"Project\" WHERE id = ph.project_id AND \"parentId\" IS NOT NULL AND \"deletedAt\" IS NULL\n )\n )\n SELECT DISTINCT user_id FROM \"UserItemAccess\"\n WHERE item_id IN (\n SELECT project_id FROM project_hierarchy\n )\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "user_id",
+ "type_info": "Text"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Text"
+ ]
+ },
+ "nullable": [
+ false
+ ]
+ },
+ "hash": "79d3bc72e6f424765706f7deea426379ae49cbd70dd122daedd95343618b9ac6"
+}
diff --git a/rust/cloud-storage/documents/.sqlx/query-96d853b887f2e6d7aac6b15ddd2b71a8d8900d2ef30047da7ca1a5940503b6d0.json b/rust/cloud-storage/documents/.sqlx/query-96d853b887f2e6d7aac6b15ddd2b71a8d8900d2ef30047da7ca1a5940503b6d0.json
new file mode 100644
index 0000000000..e42c9f2009
--- /dev/null
+++ b/rust/cloud-storage/documents/.sqlx/query-96d853b887f2e6d7aac6b15ddd2b71a8d8900d2ef30047da7ca1a5940503b6d0.json
@@ -0,0 +1,22 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n WITH RECURSIVE project_hierarchy AS (\n SELECT p.id as project_id\n FROM \"Document\" d\n JOIN \"Project\" p ON d.\"projectId\" = p.id AND p.\"deletedAt\" IS NULL\n WHERE d.id = $1 AND d.\"deletedAt\" IS NULL\n UNION ALL\n SELECT parent.id as project_id\n FROM project_hierarchy ph\n JOIN \"Project\" parent ON parent.id = (\n SELECT \"parentId\" FROM \"Project\" WHERE id = ph.project_id AND \"parentId\" IS NOT NULL AND \"deletedAt\" IS NULL\n )\n )\n SELECT DISTINCT user_id FROM \"UserItemAccess\"\n WHERE item_id IN (\n SELECT $1\n UNION\n SELECT project_id FROM project_hierarchy\n )\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "user_id",
+ "type_info": "Text"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Text"
+ ]
+ },
+ "nullable": [
+ false
+ ]
+ },
+ "hash": "96d853b887f2e6d7aac6b15ddd2b71a8d8900d2ef30047da7ca1a5940503b6d0"
+}
diff --git a/rust/cloud-storage/documents/.sqlx/query-b3aeddd507e0efee0e0cecef6eae7503820f0f3302e95a459790c5cb78e5dfb0.json b/rust/cloud-storage/documents/.sqlx/query-b3aeddd507e0efee0e0cecef6eae7503820f0f3302e95a459790c5cb78e5dfb0.json
new file mode 100644
index 0000000000..2b67c5606d
--- /dev/null
+++ b/rust/cloud-storage/documents/.sqlx/query-b3aeddd507e0efee0e0cecef6eae7503820f0f3302e95a459790c5cb78e5dfb0.json
@@ -0,0 +1,23 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n -- CTE to recursively find all parent projects for the given email thread.\n WITH RECURSIVE project_hierarchy AS (\n -- Base case: Start with the project directly associated with the thread.\n SELECT\n p.id as project_id\n FROM\n \"EmailThreadPermission\" etp\n JOIN \"Project\" p ON etp.\"projectId\" = p.id AND p.\"deletedAt\" IS NULL\n WHERE\n etp.\"threadId\" = $1\n UNION ALL\n -- Recursive case: Find the parent of the project from the previous step.\n SELECT\n parent.id as project_id\n FROM\n project_hierarchy ph\n JOIN \"Project\" parent ON parent.id = (\n SELECT \"parentId\" FROM \"Project\" WHERE id = ph.project_id AND \"parentId\" IS NOT NULL AND \"deletedAt\" IS NULL\n )\n )\n -- The subquery now gathers all levels as plain text.\n SELECT access_level FROM (\n -- Source 1: Cast the AccessLevel enum to text.\n SELECT access_level::text FROM \"UserItemAccess\"\n WHERE user_id = $2 AND item_id IN (\n SELECT $1 -- The thread ID itself\n UNION\n SELECT project_id FROM project_hierarchy -- All parent projects\n )\n UNION ALL\n -- Source 2: Select the publicAccessLevel (which is already text).\n SELECT \"publicAccessLevel\" as access_level\n FROM \"SharePermission\"\n WHERE \"isPublic\" = true AND \"publicAccessLevel\" IS NOT NULL AND id IN (\n SELECT \"sharePermissionId\" FROM \"EmailThreadPermission\" WHERE \"threadId\" = $1\n UNION\n SELECT \"sharePermissionId\" FROM \"ProjectPermission\" WHERE \"projectId\" IN (SELECT project_id FROM project_hierarchy)\n )\n ) as all_levels\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "access_level",
+ "type_info": "Text"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Text",
+ "Text"
+ ]
+ },
+ "nullable": [
+ null
+ ]
+ },
+ "hash": "b3aeddd507e0efee0e0cecef6eae7503820f0f3302e95a459790c5cb78e5dfb0"
+}
diff --git a/rust/cloud-storage/documents/.sqlx/query-e7235d6ad2033a2ff7be0bf57ab042cd71e3b3d0e1f8a9750e55cdda92e70c6f.json b/rust/cloud-storage/documents/.sqlx/query-e7235d6ad2033a2ff7be0bf57ab042cd71e3b3d0e1f8a9750e55cdda92e70c6f.json
new file mode 100644
index 0000000000..4c96ff0fd5
--- /dev/null
+++ b/rust/cloud-storage/documents/.sqlx/query-e7235d6ad2033a2ff7be0bf57ab042cd71e3b3d0e1f8a9750e55cdda92e70c6f.json
@@ -0,0 +1,22 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n WITH RECURSIVE project_hierarchy AS (\n SELECT p.id as project_id\n FROM \"EmailThreadPermission\" etp\n JOIN \"Project\" p ON etp.\"projectId\" = p.id AND p.\"deletedAt\" IS NULL\n WHERE etp.\"threadId\" = $1\n UNION ALL\n SELECT parent.id as project_id\n FROM project_hierarchy ph\n JOIN \"Project\" parent ON parent.id = (\n SELECT \"parentId\" FROM \"Project\" WHERE id = ph.project_id AND \"parentId\" IS NOT NULL AND \"deletedAt\" IS NULL\n )\n )\n SELECT DISTINCT user_id FROM \"UserItemAccess\"\n WHERE item_id IN (\n SELECT $1\n UNION\n SELECT project_id FROM project_hierarchy\n )\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "user_id",
+ "type_info": "Text"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Text"
+ ]
+ },
+ "nullable": [
+ false
+ ]
+ },
+ "hash": "e7235d6ad2033a2ff7be0bf57ab042cd71e3b3d0e1f8a9750e55cdda92e70c6f"
+}
diff --git a/rust/cloud-storage/documents/fixtures/documents_test_data.sql b/rust/cloud-storage/documents/fixtures/documents_test_data.sql
index 444c569223..cb57840220 100644
--- a/rust/cloud-storage/documents/fixtures/documents_test_data.sql
+++ b/rust/cloud-storage/documents/fixtures/documents_test_data.sql
@@ -5,18 +5,25 @@ INSERT INTO
'organization-one'
);
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id") VALUES
+ ('a1111111-1111-1111-1111-111111111111', 'user', '[email protected]', 'stripe_id'),
+ ('a2222222-2222-2222-2222-222222222222', 'teammate1', '[email protected]', 'stripe_id_t1'),
+ ('a3333333-3333-3333-3333-333333333333', 'teammate2', '[email protected]', 'stripe_id_t2');
+
INSERT INTO
public."User" (
"id",
"email",
"stripeCustomerId",
- "organizationId"
+ "organizationId",
+ "macro_user_id"
) (
SELECT
'stripe_id',
- 1
+ 1,
+ 'a1111111-1111-1111-1111-111111111111'
);
INSERT INTO
@@ -68,11 +75,11 @@ INSERT INTO
);
-- Additional users for team sharing tests
-INSERT INTO public."User" ("id", "email", "stripeCustomerId", "organizationId")
- (SELECT 'macro|[email protected]', '[email protected]', 'stripe_id_t1', 1);
+INSERT INTO public."User" ("id", "email", "stripeCustomerId", "organizationId", "macro_user_id")
+ (SELECT 'macro|[email protected]', '[email protected]', 'stripe_id_t1', 1, 'a2222222-2222-2222-2222-222222222222');
-INSERT INTO public."User" ("id", "email", "stripeCustomerId", "organizationId")
- (SELECT 'macro|[email protected]', '[email protected]', 'stripe_id_t2', 1);
+INSERT INTO public."User" ("id", "email", "stripeCustomerId", "organizationId", "macro_user_id")
+ (SELECT 'macro|[email protected]', '[email protected]', 'stripe_id_t2', 1, 'a3333333-3333-3333-3333-333333333333');
-- Team and team_user for sharing tests
INSERT INTO public."team" ("id", "name", "owner_id")
diff --git a/rust/cloud-storage/email_contact_search/fixtures/email_contacts.sql b/rust/cloud-storage/email_contact_search/fixtures/email_contacts.sql
index 549da76311..86e676de87 100644
--- a/rust/cloud-storage/email_contact_search/fixtures/email_contacts.sql
+++ b/rust/cloud-storage/email_contact_search/fixtures/email_contacts.sql
@@ -1,8 +1,14 @@
+-- Test macro_users
+INSERT INTO "macro_user" (id, username, email, stripe_customer_id)
+VALUES
+ ('b1111111-1111-1111-1111-111111111111', 'user1', '[email protected]', 'stripe_id_1'),
+ ('b2222222-2222-2222-2222-222222222222', 'user2', '[email protected]', 'stripe_id_2');
+
-- Test users
-INSERT INTO "User" (id, email, name)
+INSERT INTO "User" (id, email, name, macro_user_id)
VALUES
- ('macro|[email protected]', '[email protected]', 'Test User 1'),
- ('macro|[email protected]', '[email protected]', 'Test User 2');
+ ('macro|[email protected]', '[email protected]', 'Test User 1', 'b1111111-1111-1111-1111-111111111111'),
+ ('macro|[email protected]', '[email protected]', 'Test User 2', 'b2222222-2222-2222-2222-222222222222');
-- Email links (email account connections for each user)
INSERT INTO email_links (id, macro_id, fusionauth_user_id, email_address, provider, is_sync_active, created_at, updated_at)
diff --git a/rust/cloud-storage/frecency/src/outbound/postgres/dynamic_tests.rs b/rust/cloud-storage/frecency/src/outbound/postgres/dynamic_tests.rs
index 95bf22a105..fbc04e0cbb 100644
--- a/rust/cloud-storage/frecency/src/outbound/postgres/dynamic_tests.rs
+++ b/rust/cloud-storage/frecency/src/outbound/postgres/dynamic_tests.rs
@@ -543,15 +543,30 @@ async fn test_dynamic_filter_document_task_include_cbm_atm_nc(pool: PgPool) {
let test_user_id = MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap();
// Ensure owner row exists for foreign keys from Document.owner.
+ let macro_user_uuid = Uuid::new_v4();
sqlx::query(
r#"
- INSERT INTO "User" ("id", "email")
- VALUES ($1, $2)
+ INSERT INTO "macro_user" ("id", "username", "email", "stripe_customer_id")
+ VALUES ($1, 'test', $2, 'stripe_test')
+ ON CONFLICT ("id") DO NOTHING
+ "#,
+ )
+ .bind(macro_user_uuid)
+ .execute(&pool)
+ .await
+ .unwrap();
+
+ sqlx::query(
+ r#"
+ INSERT INTO "User" ("id", "email", "macro_user_id")
+ VALUES ($1, $2, $3)
ON CONFLICT ("id") DO NOTHING
"#,
)
.bind(test_user_id.as_ref())
+ .bind(macro_user_uuid)
.execute(&pool)
.await
.unwrap();
diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-1400e6024ad92e90369be284cd0ca35a4b9b6c1d70fb86dde1ec83a2314350d2.json b/rust/cloud-storage/macro_db_client/.sqlx/query-1400e6024ad92e90369be284cd0ca35a4b9b6c1d70fb86dde1ec83a2314350d2.json
index 10c0421446..31173c10d4 100644
--- a/rust/cloud-storage/macro_db_client/.sqlx/query-1400e6024ad92e90369be284cd0ca35a4b9b6c1d70fb86dde1ec83a2314350d2.json
+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-1400e6024ad92e90369be284cd0ca35a4b9b6c1d70fb86dde1ec83a2314350d2.json
@@ -15,7 +15,7 @@
]
},
"nullable": [
- true
+ false
]
},
"hash": "1400e6024ad92e90369be284cd0ca35a4b9b6c1d70fb86dde1ec83a2314350d2"
diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-1435acbba365796ddcb6ddbef86f4ebf664cffc44082996f6b60a60373c28f75.json b/rust/cloud-storage/macro_db_client/.sqlx/query-1435acbba365796ddcb6ddbef86f4ebf664cffc44082996f6b60a60373c28f75.json
new file mode 100644
index 0000000000..d2b084cf10
--- /dev/null
+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-1435acbba365796ddcb6ddbef86f4ebf664cffc44082996f6b60a60373c28f75.json
@@ -0,0 +1,17 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n INSERT INTO entity_properties (id, entity_id, entity_type, property_definition_id, values)\n SELECT \n u.id,\n u.entity_id,\n 'TASK'::property_entity_type,\n u.property_definition_id,\n u.values\n FROM UNNEST(\n $1::UUID[],\n $2::TEXT[],\n $3::UUID[],\n $4::JSONB[]\n ) AS u(id, entity_id, property_definition_id, values)\n ON CONFLICT (entity_id, entity_type, property_definition_id)\n DO UPDATE SET \n values = EXCLUDED.values,\n updated_at = NOW()\n ",
+ "describe": {
+ "columns": [],
+ "parameters": {
+ "Left": [
+ "UuidArray",
+ "TextArray",
+ "UuidArray",
+ "JsonbArray"
+ ]
+ },
+ "nullable": []
+ },
+ "hash": "1435acbba365796ddcb6ddbef86f4ebf664cffc44082996f6b60a60373c28f75"
+}
diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-63492b018803ce26db5891964a0f52f37d2f54bd8243265c6561f4423af8617c.json b/rust/cloud-storage/macro_db_client/.sqlx/query-63492b018803ce26db5891964a0f52f37d2f54bd8243265c6561f4423af8617c.json
new file mode 100644
index 0000000000..6d97183829
--- /dev/null
+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-63492b018803ce26db5891964a0f52f37d2f54bd8243265c6561f4423af8617c.json
@@ -0,0 +1,16 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n INSERT INTO entity_properties (id, entity_id, entity_type, property_definition_id, values)\n SELECT \n u.id,\n u.entity_id,\n 'TASK'::property_entity_type,\n u.property_definition_id,\n NULL\n FROM UNNEST(\n $1::UUID[],\n $2::TEXT[],\n $3::UUID[]\n ) AS u(id, entity_id, property_definition_id)\n ON CONFLICT (entity_id, entity_type, property_definition_id)\n DO NOTHING\n ",
+ "describe": {
+ "columns": [],
+ "parameters": {
+ "Left": [
+ "UuidArray",
+ "TextArray",
+ "UuidArray"
+ ]
+ },
+ "nullable": []
+ },
+ "hash": "63492b018803ce26db5891964a0f52f37d2f54bd8243265c6561f4423af8617c"
+}
diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-9cd40fbb1ade51e9e0d49792839d1a363cada017252a6f653c2272608189bcc4.json b/rust/cloud-storage/macro_db_client/.sqlx/query-9cd40fbb1ade51e9e0d49792839d1a363cada017252a6f653c2272608189bcc4.json
new file mode 100644
index 0000000000..9d717fa5f9
--- /dev/null
+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-9cd40fbb1ade51e9e0d49792839d1a363cada017252a6f653c2272608189bcc4.json
@@ -0,0 +1,28 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT property_definition_id, values\n FROM entity_properties\n WHERE entity_id = $1\n AND entity_type = 'TASK'\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "property_definition_id",
+ "type_info": "Uuid"
+ },
+ {
+ "ordinal": 1,
+ "name": "values",
+ "type_info": "Jsonb"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Text"
+ ]
+ },
+ "nullable": [
+ false,
+ true
+ ]
+ },
+ "hash": "9cd40fbb1ade51e9e0d49792839d1a363cada017252a6f653c2272608189bcc4"
+}
diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-cf71680da3444f573f4cddf66b6269bfe31aeee4bbec34b7e6067a855e28f2b7.json b/rust/cloud-storage/macro_db_client/.sqlx/query-cf71680da3444f573f4cddf66b6269bfe31aeee4bbec34b7e6067a855e28f2b7.json
new file mode 100644
index 0000000000..9dc9838dc0
--- /dev/null
+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-cf71680da3444f573f4cddf66b6269bfe31aeee4bbec34b7e6067a855e28f2b7.json
@@ -0,0 +1,15 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n UPDATE entity_properties\n SET values = $2\n WHERE entity_id = $1;\n ",
+ "describe": {
+ "columns": [],
+ "parameters": {
+ "Left": [
+ "Text",
+ "Jsonb"
+ ]
+ },
+ "nullable": []
+ },
+ "hash": "cf71680da3444f573f4cddf66b6269bfe31aeee4bbec34b7e6067a855e28f2b7"
+}
diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-e17eb13c62a13ec9d5355a6f632b414792f6d87963138b7969b6a8f179e508a1.json b/rust/cloud-storage/macro_db_client/.sqlx/query-e17eb13c62a13ec9d5355a6f632b414792f6d87963138b7969b6a8f179e508a1.json
index 7e554e2420..15dd620397 100644
--- a/rust/cloud-storage/macro_db_client/.sqlx/query-e17eb13c62a13ec9d5355a6f632b414792f6d87963138b7969b6a8f179e508a1.json
+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-e17eb13c62a13ec9d5355a6f632b414792f6d87963138b7969b6a8f179e508a1.json
@@ -33,7 +33,7 @@
false,
false,
true,
- true
+ false
]
},
"hash": "e17eb13c62a13ec9d5355a6f632b414792f6d87963138b7969b6a8f179e508a1"
diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-f2d5d7aea9918978cd69c14f8afe24156c2fa387e001ee8eaf57e4a70a106069.json b/rust/cloud-storage/macro_db_client/.sqlx/query-f2d5d7aea9918978cd69c14f8afe24156c2fa387e001ee8eaf57e4a70a106069.json
new file mode 100644
index 0000000000..182e0858ba
--- /dev/null
+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-f2d5d7aea9918978cd69c14f8afe24156c2fa387e001ee8eaf57e4a70a106069.json
@@ -0,0 +1,18 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n INSERT INTO entity_properties (id, entity_id, entity_type, property_definition_id, values)\n SELECT \n u.id,\n u.entity_id,\n u.entity_type::property_entity_type,\n u.property_definition_id,\n u.values\n FROM UNNEST(\n $1::UUID[],\n $2::TEXT[],\n $3::TEXT[],\n $4::UUID[],\n $5::JSONB[]\n ) AS u(id, entity_id, entity_type, property_definition_id, values)\n ON CONFLICT (entity_id, entity_type, property_definition_id)\n DO UPDATE SET \n values = EXCLUDED.values,\n updated_at = NOW()\n ",
+ "describe": {
+ "columns": [],
+ "parameters": {
+ "Left": [
+ "UuidArray",
+ "TextArray",
+ "TextArray",
+ "UuidArray",
+ "JsonbArray"
+ ]
+ },
+ "nullable": []
+ },
+ "hash": "f2d5d7aea9918978cd69c14f8afe24156c2fa387e001ee8eaf57e4a70a106069"
+}
diff --git a/rust/cloud-storage/macro_db_client/fixtures/basic_document_summary.sql b/rust/cloud-storage/macro_db_client/fixtures/basic_document_summary.sql
index 095cd5ad44..35c70dfb18 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/basic_document_summary.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/basic_document_summary.sql
@@ -1,10 +1,14 @@
-- Create a test user
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', 'user', '[email protected]', 'stripe_id');
+
INSERT INTO
- public."User" ("id", "email", "stripeCustomerId")
+ public."User" ("id", "email", "stripeCustomerId", "macro_user_id")
VALUES (
- 'stripe_id'
+ 'stripe_id',
+ 'a1111111-1111-1111-1111-111111111111'
);
-- Create test documents
diff --git a/rust/cloud-storage/macro_db_client/fixtures/basic_pinned_document.sql b/rust/cloud-storage/macro_db_client/fixtures/basic_pinned_document.sql
index 22080a59f5..9cfad7226c 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/basic_pinned_document.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/basic_pinned_document.sql
@@ -1,5 +1,7 @@
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', 'user', '[email protected]', 'stripe_id');
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id', 'a1111111-1111-1111-1111-111111111111');
INSERT INTO public."Document" ("id","name","fileType", "owner", "createdAt", "updatedAt")
(SELECT 'document-one', 'test_document_name','pdf', 'macro|[email protected]', '2019-10-16 00:00:00', '2019-10-16 00:00:00');
diff --git a/rust/cloud-storage/macro_db_client/fixtures/basic_user_history.sql b/rust/cloud-storage/macro_db_client/fixtures/basic_user_history.sql
index cce77b4934..482720c2ad 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/basic_user_history.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/basic_user_history.sql
@@ -1,20 +1,31 @@
INSERT INTO public."Organization" ("id","name")
(SELECT 1, 'organization-one');
-INSERT INTO public."User" ("id","email","stripeCustomerId", "organizationId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id', 1);
-
-INSERT INTO public."User" ("id","email","stripeCustomerId", "organizationId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id2', 1);
-
-INSERT INTO public."User" ("id","email","stripeCustomerId", "organizationId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id3', 1);
-
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id4');
-
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id5');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+(SELECT 'a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_id');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+(SELECT 'a2222222-2222-2222-2222-222222222222', '[email protected]', '[email protected]', 'stripe_id2');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+(SELECT 'a3333333-3333-3333-3333-333333333333', '[email protected]', '[email protected]', 'stripe_id3');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+(SELECT 'a4444444-4444-4444-4444-444444444444', '[email protected]', '[email protected]', 'stripe_id4');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+(SELECT 'a5555555-5555-5555-5555-555555555555', '[email protected]', '[email protected]', 'stripe_id5');
+
+INSERT INTO public."User" ("id","email","stripeCustomerId", "organizationId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id', 1, 'a1111111-1111-1111-1111-111111111111');
+
+INSERT INTO public."User" ("id","email","stripeCustomerId", "organizationId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id2', 1, 'a2222222-2222-2222-2222-222222222222');
+
+INSERT INTO public."User" ("id","email","stripeCustomerId", "organizationId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id3', 1, 'a3333333-3333-3333-3333-333333333333');
+
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id4', 'a4444444-4444-4444-4444-444444444444');
+
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id5', 'a5555555-5555-5555-5555-555555555555');
INSERT INTO public."Document" ("id","name","fileType", "owner", "createdAt", "updatedAt")
(SELECT 'document-one', 'test_document_name','pdf', 'macro|[email protected]', '2019-10-16 00:00:00', '2019-10-16 00:00:00');
diff --git a/rust/cloud-storage/macro_db_client/fixtures/basic_user_with_document.sql b/rust/cloud-storage/macro_db_client/fixtures/basic_user_with_document.sql
index d2198c28da..dbb809f2a7 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/basic_user_with_document.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/basic_user_with_document.sql
@@ -1,5 +1,8 @@
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_id');
+
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id', 'a1111111-1111-1111-1111-111111111111');
INSERT INTO public."Document" ("id","name","fileType", "owner")
(SELECT 'document-one', 'test_document_name','pdf', 'macro|[email protected]');
diff --git a/rust/cloud-storage/macro_db_client/fixtures/basic_user_with_documents.sql b/rust/cloud-storage/macro_db_client/fixtures/basic_user_with_documents.sql
index 9fd6e236f5..3b6f09a71e 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/basic_user_with_documents.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/basic_user_with_documents.sql
@@ -5,26 +5,33 @@ INSERT INTO
'organization-one'
);
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id") VALUES
+ ('a1111111-1111-1111-1111-111111111111', 'user', '[email protected]', 'stripe_id'),
+ ('a2222222-2222-2222-2222-222222222222', 'user2', '[email protected]', 'stripe_id2');
+
INSERT INTO
public."User" (
"id",
"email",
"stripeCustomerId",
- "organizationId"
+ "organizationId",
+ "macro_user_id"
) (
SELECT
'stripe_id',
- 1
+ 1,
+ 'a1111111-1111-1111-1111-111111111111'
);
INSERT INTO
- public."User" ("id", "email", "stripeCustomerId") (
+ public."User" ("id", "email", "stripeCustomerId", "macro_user_id") (
SELECT
- 'stripe_id2'
+ 'stripe_id2',
+ 'a2222222-2222-2222-2222-222222222222'
);
INSERT INTO
diff --git a/rust/cloud-storage/macro_db_client/fixtures/basic_user_with_lots_of_documents.sql b/rust/cloud-storage/macro_db_client/fixtures/basic_user_with_lots_of_documents.sql
index ccfbf6daf2..5f7fd131e6 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/basic_user_with_lots_of_documents.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/basic_user_with_lots_of_documents.sql
@@ -1,5 +1,8 @@
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', 'user', '[email protected]', 'stripe_id');
+
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id','a1111111-1111-1111-1111-111111111111');
INSERT INTO public."Project" ("id", "name", "userId")
(SELECT 'project-one', 'test_project_name', 'macro|[email protected]');
diff --git a/rust/cloud-storage/macro_db_client/fixtures/basic_user_with_permissions.sql b/rust/cloud-storage/macro_db_client/fixtures/basic_user_with_permissions.sql
index cc4aaffb5a..d50aee80bb 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/basic_user_with_permissions.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/basic_user_with_permissions.sql
@@ -1,6 +1,10 @@
-INSERT INTO "User" ("id", "email", "name", "stripeCustomerId") VALUES
-('macro|[email protected]', '[email protected]', 'User', 'cus_1234'),
-('macro|[email protected]', '[email protected]', 'User2', 'cus_12345');
+INSERT INTO "macro_user" ("id", "username", "email", "stripe_customer_id") VALUES
+('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'cus_1234'),
+('a2222222-2222-2222-2222-222222222222', '[email protected]', '[email protected]', 'cus_12345');
+
+INSERT INTO "User" ("id", "email", "name", "stripeCustomerId", "macro_user_id") VALUES
+('macro|[email protected]', '[email protected]', 'User', 'cus_1234', 'a1111111-1111-1111-1111-111111111111'),
+('macro|[email protected]', '[email protected]', 'User2', 'cus_12345', 'a2222222-2222-2222-2222-222222222222');
INSERT INTO "Permission" ("id", "description") VALUES
('permission-one', 'Permission One'),
diff --git a/rust/cloud-storage/macro_db_client/fixtures/basic_versioned_document.sql b/rust/cloud-storage/macro_db_client/fixtures/basic_versioned_document.sql
index 66e3005d1f..b7adb1296c 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/basic_versioned_document.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/basic_versioned_document.sql
@@ -1,5 +1,8 @@
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_id');
+
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id', 'a1111111-1111-1111-1111-111111111111');
INSERT INTO public."Document" ("id","name","fileType", "owner")
(SELECT 'document-one', 'test_document_name','pdf', 'macro|[email protected]');
diff --git a/rust/cloud-storage/macro_db_client/fixtures/channel_share_permissions.sql b/rust/cloud-storage/macro_db_client/fixtures/channel_share_permissions.sql
index a8d348b959..ad167750e3 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/channel_share_permissions.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/channel_share_permissions.sql
@@ -1,7 +1,12 @@
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-VALUES
-('macro|[email protected]', '[email protected]','stripe_id'),
-('macro|[email protected]', '[email protected]','stripe_id2');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES
+('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_id'),
+('a2222222-2222-2222-2222-222222222222', '[email protected]', '[email protected]', 'stripe_id2');
+
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+VALUES
+('macro|[email protected]', '[email protected]','stripe_id', 'a1111111-1111-1111-1111-111111111111'),
+('macro|[email protected]', '[email protected]','stripe_id2', 'a2222222-2222-2222-2222-222222222222');
INSERT INTO public."Project" ("id","name","userId","parentId","createdAt","updatedAt")
VALUES
diff --git a/rust/cloud-storage/macro_db_client/fixtures/chat_example.sql b/rust/cloud-storage/macro_db_client/fixtures/chat_example.sql
index bbd2a92394..99de656aa7 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/chat_example.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/chat_example.sql
@@ -1,5 +1,8 @@
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-VALUES ('macro|[email protected]', '[email protected]','stripe_id');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', 'user', '[email protected]', 'stripe_id');
+
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+VALUES ('macro|[email protected]', '[email protected]','stripe_id','a1111111-1111-1111-1111-111111111111');
-- Test Documents
INSERT INTO public."Document" ("id","name","fileType", "owner")
diff --git a/rust/cloud-storage/macro_db_client/fixtures/chat_permissions.sql b/rust/cloud-storage/macro_db_client/fixtures/chat_permissions.sql
index a102653e98..16e2c5950b 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/chat_permissions.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/chat_permissions.sql
@@ -1,8 +1,11 @@
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', 'user', '[email protected]', 'stripe_id'),
+ ('a2222222-2222-2222-2222-222222222222', 'user2', '[email protected]', 'stripe_id2');
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id', 'a1111111-1111-1111-1111-111111111111');
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id2');
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id2', 'a2222222-2222-2222-2222-222222222222');
INSERT INTO public."Chat" ("id", "name", "userId", "createdAt", "updatedAt")
(SELECT 'chat-one', 'test_chat_name','macro|[email protected]', '2019-10-16 00:00:00', '2019-10-16 00:00:00');
diff --git a/rust/cloud-storage/macro_db_client/fixtures/chat_with_attachment_summaries.sql b/rust/cloud-storage/macro_db_client/fixtures/chat_with_attachment_summaries.sql
index 469e0cd118..1f467f5b26 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/chat_with_attachment_summaries.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/chat_with_attachment_summaries.sql
@@ -1,11 +1,15 @@
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', 'test', '[email protected]', 'stripe_id');
+
INSERT INTO
public."User"
- ("id", "email", "stripeCustomerId")
+ ("id", "email", "stripeCustomerId", "macro_user_id")
VALUES
(
'test-userid',
- 'stripe_id'
+ 'stripe_id',
+ 'a1111111-1111-1111-1111-111111111111'
);
INSERT INTO
diff --git a/rust/cloud-storage/macro_db_client/fixtures/count.sql b/rust/cloud-storage/macro_db_client/fixtures/count.sql
index f981fdaf81..d1bbf43662 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/count.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/count.sql
@@ -1,5 +1,8 @@
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+(SELECT 'a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_id');
+
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id', 'a1111111-1111-1111-1111-111111111111');
INSERT INTO public."Document" ("id","name","fileType", "owner")
(SELECT 'd1', 'test_document_name','txt', 'macro|[email protected]');
diff --git a/rust/cloud-storage/macro_db_client/fixtures/dcs_basic_user_with_documents.sql b/rust/cloud-storage/macro_db_client/fixtures/dcs_basic_user_with_documents.sql
index f5ff6ce746..8c273eb9f8 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/dcs_basic_user_with_documents.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/dcs_basic_user_with_documents.sql
@@ -1,14 +1,19 @@
INSERT INTO public."Organization" ("id", "name")
(SELECT 1, 'test-org');
-INSERT INTO public."User" ("id","email","stripeCustomerId", "organizationId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id', 1);
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id") VALUES
+ ('a1111111-1111-1111-1111-111111111111', 'user', '[email protected]', 'stripe_id'),
+ ('a2222222-2222-2222-2222-222222222222', 'user2', '[email protected]', 'stripe_id2'),
+ ('a3333333-3333-3333-3333-333333333333', 'user3', '[email protected]', 'stripe_id3');
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id2');
+INSERT INTO public."User" ("id","email","stripeCustomerId", "organizationId", "macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id', 1, 'a1111111-1111-1111-1111-111111111111');
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id3');
+INSERT INTO public."User" ("id","email","stripeCustomerId", "macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id2', 'a2222222-2222-2222-2222-222222222222');
+
+INSERT INTO public."User" ("id","email","stripeCustomerId", "macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id3', 'a3333333-3333-3333-3333-333333333333');
INSERT INTO public."Project" ("id", "name", "userId", "createdAt", "updatedAt")
(SELECT 'project-one', 'b', 'macro|[email protected]', '2019-10-16 00:00:00', '2019-10-16 04:00:00');
diff --git a/rust/cloud-storage/macro_db_client/fixtures/dcs_document_text.sql b/rust/cloud-storage/macro_db_client/fixtures/dcs_document_text.sql
index ae8575fb11..ce2a47e114 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/dcs_document_text.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/dcs_document_text.sql
@@ -1,5 +1,8 @@
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', 'user', '[email protected]', 'stripe_id');
+
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id','a1111111-1111-1111-1111-111111111111');
INSERT INTO public."Document" ("id","name","fileType", "owner")
(SELECT 'document-one', 'test_document_name','pdf', 'macro|[email protected]');
diff --git a/rust/cloud-storage/macro_db_client/fixtures/document_access_via_email_thread.sql b/rust/cloud-storage/macro_db_client/fixtures/document_access_via_email_thread.sql
index f671f3bedd..2e50228967 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/document_access_via_email_thread.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/document_access_via_email_thread.sql
@@ -10,10 +10,14 @@ TRUNCATE TABLE public."User", public."Project", public."Document", public."Share
------------------------------------------------------------
-- Users
------------------------------------------------------------
-INSERT INTO public."User" ("id", "email")
-VALUES ('user-thread-access', '[email protected]'), -- Has thread access only
- ('user-no-access', '[email protected]'), -- Has no access at all
- ('user-both-access', '[email protected]'); -- Has both direct doc and thread access
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', 'user_thread', '[email protected]', 'stripe_user_thread'),
+ ('a2222222-2222-2222-2222-222222222222', 'user_none', '[email protected]', 'stripe_user_none'),
+ ('a3333333-3333-3333-3333-333333333333', 'user_both', '[email protected]', 'stripe_user_both');
+INSERT INTO public."User" ("id", "email", "macro_user_id")
+VALUES ('user-thread-access', '[email protected]', 'a1111111-1111-1111-1111-111111111111'), -- Has thread access only
+ ('user-no-access', '[email protected]', 'a2222222-2222-2222-2222-222222222222'), -- Has no access at all
+ ('user-both-access', '[email protected]', 'a3333333-3333-3333-3333-333333333333'); -- Has both direct doc and thread access
------------------------------------------------------------
-- Email infrastructure: link, thread, message, attachment
diff --git a/rust/cloud-storage/macro_db_client/fixtures/document_pdf_comments_and_highlights.sql b/rust/cloud-storage/macro_db_client/fixtures/document_pdf_comments_and_highlights.sql
index c9e7b7d99a..84a383bebd 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/document_pdf_comments_and_highlights.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/document_pdf_comments_and_highlights.sql
@@ -4,28 +4,36 @@ INSERT INTO
VALUES
(1, 'organization-one');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES
+ ('a1111111-1111-1111-1111-111111111111', 'user', '[email protected]', 'stripe_id'),
+ ('a2222222-2222-2222-2222-222222222222', 'user2', '[email protected]', 'stripe_id2');
+
INSERT INTO
public."User" (
"id",
"email",
"stripeCustomerId",
- "organizationId"
+ "organizationId",
+ "macro_user_id"
)
VALUES
(
'stripe_id',
- 1
+ 1,
+ 'a1111111-1111-1111-1111-111111111111'
);
INSERT INTO
- public."User" ("id", "email", "stripeCustomerId")
+ public."User" ("id", "email", "stripeCustomerId", "macro_user_id")
VALUES
(
- 'stripe_id2'
+ 'stripe_id2',
+ 'a2222222-2222-2222-2222-222222222222'
);
--------------------------------------------------
diff --git a/rust/cloud-storage/macro_db_client/fixtures/document_permissions.sql b/rust/cloud-storage/macro_db_client/fixtures/document_permissions.sql
index 925858c48e..d89379feeb 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/document_permissions.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/document_permissions.sql
@@ -1,8 +1,12 @@
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_id'),
+ ('a2222222-2222-2222-2222-222222222222', '[email protected]', '[email protected]', 'stripe_id2');
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id2');
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id', 'a1111111-1111-1111-1111-111111111111');
+
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id2', 'a2222222-2222-2222-2222-222222222222');
INSERT INTO public."Document" ("id","name","fileType", "owner", "createdAt", "updatedAt")
(SELECT 'document-one', 'test_document_name','pdf', 'macro|[email protected]', '2019-10-16 00:00:00', '2019-10-16 00:00:00');
diff --git a/rust/cloud-storage/macro_db_client/fixtures/document_preview.sql b/rust/cloud-storage/macro_db_client/fixtures/document_preview.sql
index 58def7656a..ea588a1b16 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/document_preview.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/document_preview.sql
@@ -1,7 +1,10 @@
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-VALUES ('macro|[email protected]', '[email protected]','stripe_id');
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-VALUES ('macro|[email protected]', '[email protected]','stripe_iddfkjdfkdf');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', 'user', '[email protected]', 'stripe_id'),
+ ('a2222222-2222-2222-2222-222222222222', 'other', '[email protected]', 'stripe_iddfkjdfkdf');
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+VALUES ('macro|[email protected]', '[email protected]','stripe_id', 'a1111111-1111-1111-1111-111111111111');
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+VALUES ('macro|[email protected]', '[email protected]','stripe_iddfkjdfkdf', 'a2222222-2222-2222-2222-222222222222');
INSERT INTO public."Document" ("id","name","fileType", "owner", "createdAt", "updatedAt")
VALUES ('document-one', 'test_document_name','pdf', 'macro|[email protected]', '2019-10-16 00:00:00', '2019-10-16 00:00:00');
diff --git a/rust/cloud-storage/macro_db_client/fixtures/document_process_results.sql b/rust/cloud-storage/macro_db_client/fixtures/document_process_results.sql
index b37e91e2d7..34f530ffc9 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/document_process_results.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/document_process_results.sql
@@ -1,5 +1,7 @@
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', 'user', '[email protected]', 'stripe_id');
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id', 'a1111111-1111-1111-1111-111111111111');
INSERT INTO public."Document" ("id","name","fileType", "owner", "createdAt", "updatedAt")
(SELECT 'document-one', 'test_document_name','pdf', 'macro|[email protected]', '2019-10-16 00:00:00', '2019-10-16 00:00:00');
diff --git a/rust/cloud-storage/macro_db_client/fixtures/document_text.sql b/rust/cloud-storage/macro_db_client/fixtures/document_text.sql
index e4c6bae324..6711af0111 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/document_text.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/document_text.sql
@@ -1,5 +1,8 @@
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_id');
+
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id', 'a1111111-1111-1111-1111-111111111111');
INSERT INTO public."Document" ("id","name","fileType", "owner")
(SELECT 'document-one', 'test_document_name','txt', 'macro|[email protected]');
diff --git a/rust/cloud-storage/macro_db_client/fixtures/document_text_verify.sql b/rust/cloud-storage/macro_db_client/fixtures/document_text_verify.sql
index d7e3b276aa..4e85dfbb24 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/document_text_verify.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/document_text_verify.sql
@@ -1,5 +1,8 @@
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', 'user', '[email protected]', 'stripe_id');
+
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id','a1111111-1111-1111-1111-111111111111');
INSERT INTO public."Document" ("id","name","fileType", "owner")
(SELECT 'document-one', 'document two','pdf', 'macro|[email protected]');
diff --git a/rust/cloud-storage/macro_db_client/fixtures/docx_example.sql b/rust/cloud-storage/macro_db_client/fixtures/docx_example.sql
index 3ac4be0526..90247ca02a 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/docx_example.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/docx_example.sql
@@ -1,5 +1,8 @@
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', 'user', '[email protected]', 'stripe_id');
+
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id','a1111111-1111-1111-1111-111111111111');
INSERT INTO public."Document" ("id","name","fileType", "owner", "createdAt", "updatedAt")
(SELECT 'document-one', 'test_document_name','pdf', 'macro|[email protected]', '2019-10-16 00:00:00', '2019-10-16 00:00:00');
diff --git a/rust/cloud-storage/macro_db_client/fixtures/entity_filter_tests.sql b/rust/cloud-storage/macro_db_client/fixtures/entity_filter_tests.sql
index 53d16713d0..487864c3b4 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/entity_filter_tests.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/entity_filter_tests.sql
@@ -14,11 +14,8 @@ ON CONFLICT DO NOTHING;
INSERT INTO public.macro_user (id, username, email, stripe_customer_id)
VALUES ('00000000-0000-0000-0000-000000000001', 'testuser1', '[email protected]', 'stripe_mu_1')
ON CONFLICT DO NOTHING;
-
--- Insert user
INSERT INTO public."User" ("id", "email", "stripeCustomerId", "organizationId", "macro_user_id")
-VALUES ('macro|[email protected]', '[email protected]', 'stripe_id_1', 1, '00000000-0000-0000-0000-000000000001')
-ON CONFLICT DO NOTHING;
+VALUES ('macro|[email protected]', '[email protected]', 'stripe_id_1', 1, '00000000-0000-0000-0000-000000000001');
---------------------------------
-- PROJECT HIERARCHY SETUP with UUIDs
diff --git a/rust/cloud-storage/macro_db_client/fixtures/expanded_cursor_soup_exhaustive.sql b/rust/cloud-storage/macro_db_client/fixtures/expanded_cursor_soup_exhaustive.sql
index eddb4155f6..b796eed6b5 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/expanded_cursor_soup_exhaustive.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/expanded_cursor_soup_exhaustive.sql
@@ -34,9 +34,12 @@ INSERT INTO public."Organization" ("id", "name", "status")
VALUES (1, 'Test Organization', 'PILOT')
ON CONFLICT DO NOTHING;
-INSERT INTO public."User" ("id", "email", "stripeCustomerId", "organizationId")
-VALUES ('macro|[email protected]', '[email protected]', 'stripe_id_1', 1),
- ('macro|[email protected]', '[email protected]', 'stripe_id_2', 1)
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', 'user1', '[email protected]', 'stripe_id_1'),
+ ('a2222222-2222-2222-2222-222222222222', 'user2', '[email protected]', 'stripe_id_2');
+INSERT INTO public."User" ("id", "email", "stripeCustomerId", "organizationId", "macro_user_id")
+VALUES ('macro|[email protected]', '[email protected]', 'stripe_id_1', 1, 'a1111111-1111-1111-1111-111111111111'),
+ ('macro|[email protected]', '[email protected]', 'stripe_id_2', 1, 'a2222222-2222-2222-2222-222222222222')
ON CONFLICT DO NOTHING;
---------------------------------
diff --git a/rust/cloud-storage/macro_db_client/fixtures/get_user_accessible_items_explicit.sql b/rust/cloud-storage/macro_db_client/fixtures/get_user_accessible_items_explicit.sql
index f4a0d81659..c70ea87c02 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/get_user_accessible_items_explicit.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/get_user_accessible_items_explicit.sql
@@ -8,9 +8,12 @@ SET session_replication_role = 'replica';
INSERT INTO public."Organization" ("id", "name", "status")
VALUES (1, 'Test Org', 'PILOT')
ON CONFLICT DO NOTHING;
-INSERT INTO public."User" ("id", "email", "stripeCustomerId", "organizationId")
-VALUES ('user-1', '[email protected]', 'stripe_1', 1),
- ('user-2', '[email protected]', 'stripe_2', 1);
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_1'),
+ ('a2222222-2222-2222-2222-222222222222', '[email protected]', '[email protected]', 'stripe_2');
+INSERT INTO public."User" ("id", "email", "stripeCustomerId", "organizationId", "macro_user_id")
+VALUES ('user-1', '[email protected]', 'stripe_1', 1, 'a1111111-1111-1111-1111-111111111111'),
+ ('user-2', '[email protected]', 'stripe_2', 1, 'a2222222-2222-2222-2222-222222222222');
-- === Items Owned by user-1 ===
INSERT INTO public."Project" ("id", "name", "userId")
diff --git a/rust/cloud-storage/macro_db_client/fixtures/get_user_accessible_items_implicit.sql b/rust/cloud-storage/macro_db_client/fixtures/get_user_accessible_items_implicit.sql
index 09c394fa6d..0bcf65c914 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/get_user_accessible_items_implicit.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/get_user_accessible_items_implicit.sql
@@ -9,9 +9,12 @@ SET session_replication_role = 'replica';
INSERT INTO public."Organization" ("id", "name", "status")
VALUES (1, 'Test Org', 'PILOT')
ON CONFLICT DO NOTHING;
-INSERT INTO public."User" ("id", "email", "stripeCustomerId", "organizationId")
-VALUES ('user-1', '[email protected]', 'stripe_1', 1), -- The user being tested (gains access)
- ('user-2', '[email protected]', 'stripe_2', 1);
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', 'user1', '[email protected]', 'stripe_1'),
+ ('a2222222-2222-2222-2222-222222222222', 'user2', '[email protected]', 'stripe_2');
+INSERT INTO public."User" ("id", "email", "stripeCustomerId", "organizationId", "macro_user_id")
+VALUES ('user-1', '[email protected]', 'stripe_1', 1, 'a1111111-1111-1111-1111-111111111111'), -- The user being tested (gains access)
+ ('user-2', '[email protected]', 'stripe_2', 1, 'a2222222-2222-2222-2222-222222222222');
-- The owner of the items
-- === Project Hierarchy (owned by user-2) ===
diff --git a/rust/cloud-storage/macro_db_client/fixtures/get_user_accessible_items_nested.sql b/rust/cloud-storage/macro_db_client/fixtures/get_user_accessible_items_nested.sql
index b4beda56f5..f000ac0240 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/get_user_accessible_items_nested.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/get_user_accessible_items_nested.sql
@@ -10,9 +10,12 @@ SET session_replication_role = 'replica';
INSERT INTO public."Organization" ("id", "name", "status")
VALUES (1, 'Test Org', 'PILOT')
ON CONFLICT DO NOTHING;
-INSERT INTO public."User" ("id", "email", "stripeCustomerId", "organizationId")
-VALUES ('user-1', '[email protected]', 'stripe_1', 1), -- The user being tested (gains access)
- ('user-2', '[email protected]', 'stripe_2', 1);
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_1'),
+ ('a2222222-2222-2222-2222-222222222222', '[email protected]', '[email protected]', 'stripe_2');
+INSERT INTO public."User" ("id", "email", "stripeCustomerId", "organizationId", "macro_user_id")
+VALUES ('user-1', '[email protected]', 'stripe_1', 1, 'a1111111-1111-1111-1111-111111111111'), -- The user being tested (gains access)
+ ('user-2', '[email protected]', 'stripe_2', 1, 'a2222222-2222-2222-2222-222222222222');
-- The owner of the items
-- === Project Hierarchy (A -> B -> C, owned by user-2) ===
diff --git a/rust/cloud-storage/macro_db_client/fixtures/get_user_accessible_items_unaccessible.sql b/rust/cloud-storage/macro_db_client/fixtures/get_user_accessible_items_unaccessible.sql
index 82e870015c..d831fd26e5 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/get_user_accessible_items_unaccessible.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/get_user_accessible_items_unaccessible.sql
@@ -10,10 +10,14 @@ SET session_replication_role = 'replica';
INSERT INTO public."Organization" ("id", "name", "status")
VALUES (1, 'Test Org', 'PILOT')
ON CONFLICT DO NOTHING;
-INSERT INTO public."User" ("id", "email", "stripeCustomerId", "organizationId")
-VALUES ('user-1', '[email protected]', 'stripe_1', 1), -- The owner
- ('user-2', '[email protected]', 'stripe_2', 1), -- The user with shared access
- ('user-3', '[email protected]', 'stripe_3', 1);
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_1'),
+ ('a2222222-2222-2222-2222-222222222222', '[email protected]', '[email protected]', 'stripe_2'),
+ ('a3333333-3333-3333-3333-333333333333', '[email protected]', '[email protected]', 'stripe_3');
+INSERT INTO public."User" ("id", "email", "stripeCustomerId", "organizationId", "macro_user_id")
+VALUES ('user-1', '[email protected]', 'stripe_1', 1, 'a1111111-1111-1111-1111-111111111111'), -- The owner
+ ('user-2', '[email protected]', 'stripe_2', 1, 'a2222222-2222-2222-2222-222222222222'), -- The user with shared access
+ ('user-3', '[email protected]', 'stripe_3', 1, 'a3333333-3333-3333-3333-333333333333');
-- The isolated user (test subject)
-- === Project Hierarchy (owned by user-1) ===
diff --git a/rust/cloud-storage/macro_db_client/fixtures/highest_access_level_for_chat.sql b/rust/cloud-storage/macro_db_client/fixtures/highest_access_level_for_chat.sql
index f1c0b7dd38..5c6ee637a5 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/highest_access_level_for_chat.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/highest_access_level_for_chat.sql
@@ -5,11 +5,17 @@ TRUNCATE TABLE public."User", public."Project", public."Chat", public."SharePerm
-- user-1: The primary user we will test against, has many explicit permissions.
-- user-2: Has some overlapping explicit permissions to test user scoping.
-- user-public-access-only: Has no explicit permissions, to test reliance on public access.
-INSERT INTO public."User" ("id", "email")
-VALUES ('user-1', '[email protected]'),
- ('user-2', '[email protected]'),
- ('user-3', '[email protected]'),
- ('user-public-access-only', '[email protected]');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_user1'),
+ ('a2222222-2222-2222-2222-222222222222', '[email protected]', '[email protected]', 'stripe_user2'),
+ ('a3333333-3333-3333-3333-333333333333', '[email protected]', '[email protected]', 'stripe_user3'),
+ ('a4444444-4444-4444-4444-444444444444', '[email protected]', '[email protected]', 'stripe_user4');
+
+INSERT INTO public."User" ("id", "email", "macro_user_id")
+VALUES ('user-1', '[email protected]', 'a1111111-1111-1111-1111-111111111111'),
+ ('user-2', '[email protected]', 'a2222222-2222-2222-2222-222222222222'),
+ ('user-3', '[email protected]', 'a3333333-3333-3333-3333-333333333333'),
+ ('user-public-access-only', '[email protected]', 'a4444444-4444-4444-4444-444444444444');
-- Create a nested project hierarchy: p-grandparent -> p-parent.
INSERT INTO public."Project" ("id", "name", "userId", "parentId")
diff --git a/rust/cloud-storage/macro_db_client/fixtures/highest_access_level_for_document.sql b/rust/cloud-storage/macro_db_client/fixtures/highest_access_level_for_document.sql
index 9544b7d2a9..2a94e76070 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/highest_access_level_for_document.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/highest_access_level_for_document.sql
@@ -5,11 +5,17 @@ TRUNCATE TABLE public."User", public."Project", public."Document", public."Share
-- user-1: The primary user we will test against, has many explicit permissions.
-- user-2: Has some overlapping explicit permissions to test user scoping.
-- user-public-access-only: Has no explicit permissions, to test reliance on public access.
-INSERT INTO public."User" ("id", "email")
-VALUES ('user-1', '[email protected]'),
- ('user-2', '[email protected]'),
- ('user-3', '[email protected]'),
- ('user-public-access-only', '[email protected]');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_user1'),
+ ('a2222222-2222-2222-2222-222222222222', '[email protected]', '[email protected]', 'stripe_user2'),
+ ('a3333333-3333-3333-3333-333333333333', '[email protected]', '[email protected]', 'stripe_user3'),
+ ('a4444444-4444-4444-4444-444444444444', '[email protected]', '[email protected]', 'stripe_user4');
+
+INSERT INTO public."User" ("id", "email", "macro_user_id")
+VALUES ('user-1', '[email protected]', 'a1111111-1111-1111-1111-111111111111'),
+ ('user-2', '[email protected]', 'a2222222-2222-2222-2222-222222222222'),
+ ('user-3', '[email protected]', 'a3333333-3333-3333-3333-333333333333'),
+ ('user-public-access-only', '[email protected]', 'a4444444-4444-4444-4444-444444444444');
-- Create a nested project hierarchy: p-grandparent -> p-parent.
INSERT INTO public."Project" ("id", "name", "userId", "parentId")
diff --git a/rust/cloud-storage/macro_db_client/fixtures/highest_access_level_for_project.sql b/rust/cloud-storage/macro_db_client/fixtures/highest_access_level_for_project.sql
index dc23881fed..5df51eb5c7 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/highest_access_level_for_project.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/highest_access_level_for_project.sql
@@ -2,10 +2,14 @@
TRUNCATE TABLE public."User", public."Project", public."SharePermission", public."ProjectPermission", public."UserItemAccess" RESTART IDENTITY CASCADE;
-- Create users with different permission profiles.
-INSERT INTO public."User" ("id", "email")
-VALUES ('user-1', '[email protected]'), -- Has deep explicit access grants.
- ('user-2', '[email protected]'), -- Has a single, lower-level explicit grant.
- ('user-public-access-only', '[email protected]');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', 'user1', '[email protected]', 'stripe_user1'),
+ ('a2222222-2222-2222-2222-222222222222', 'user2', '[email protected]', 'stripe_user2'),
+ ('a3333333-3333-3333-3333-333333333333', 'user3', '[email protected]', 'stripe_user3');
+INSERT INTO public."User" ("id", "email", "macro_user_id")
+VALUES ('user-1', '[email protected]', 'a1111111-1111-1111-1111-111111111111'), -- Has deep explicit access grants.
+ ('user-2', '[email protected]', 'a2222222-2222-2222-2222-222222222222'), -- Has a single, lower-level explicit grant.
+ ('user-public-access-only', '[email protected]', 'a3333333-3333-3333-3333-333333333333');
-- Has no explicit grants, relies on public access.
-- Create a nested project hierarchy: p-grandparent -> p-parent -> p-child.
diff --git a/rust/cloud-storage/macro_db_client/fixtures/highest_access_level_for_thread.sql b/rust/cloud-storage/macro_db_client/fixtures/highest_access_level_for_thread.sql
index c9bf9bad4e..b739597fad 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/highest_access_level_for_thread.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/highest_access_level_for_thread.sql
@@ -1,11 +1,17 @@
-- Clean up all relevant tables to ensure a fresh state for each test.
TRUNCATE TABLE public."User", public."Project", public."SharePermission", public."EmailThreadPermission", public."ProjectPermission", public."UserItemAccess" RESTART IDENTITY CASCADE;
+-- Create macro_user entries (must exist before User rows).
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_user1'),
+ ('a2222222-2222-2222-2222-222222222222', '[email protected]', '[email protected]', 'stripe_user2'),
+ ('a3333333-3333-3333-3333-333333333333', '[email protected]', '[email protected]', 'stripe_user3');
+
-- Create users with different permission profiles.
-INSERT INTO public."User" ("id", "email")
-VALUES ('user-1', '[email protected]'), -- Has deep explicit access grants.
- ('user-2', '[email protected]'), -- Has a single, lower-level explicit grant.
- ('user-public-access-only', '[email protected]');
+INSERT INTO public."User" ("id", "email", "macro_user_id")
+VALUES ('user-1', '[email protected]', 'a1111111-1111-1111-1111-111111111111'), -- Has deep explicit access grants.
+ ('user-2', '[email protected]', 'a2222222-2222-2222-2222-222222222222'), -- Has a single, lower-level explicit grant.
+ ('user-public-access-only', '[email protected]', 'a3333333-3333-3333-3333-333333333333');
-- Has no explicit grants, relies on public access.
-- Create a nested project hierarchy: p-grandparent -> p-parent.
diff --git a/rust/cloud-storage/macro_db_client/fixtures/history.sql b/rust/cloud-storage/macro_db_client/fixtures/history.sql
index 8bd81768bd..eed5ee11a1 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/history.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/history.sql
@@ -1,9 +1,13 @@
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', 'user', '[email protected]', 'stripe_id');
+
INSERT INTO
- public."User" ("id", "email", "stripeCustomerId") (
+ public."User" ("id", "email", "stripeCustomerId", "macro_user_id") (
SELECT
- 'stripe_id'
+ 'stripe_id',
+ 'a1111111-1111-1111-1111-111111111111'
);
INSERT INTO
diff --git a/rust/cloud-storage/macro_db_client/fixtures/insights_backfill.sql b/rust/cloud-storage/macro_db_client/fixtures/insights_backfill.sql
index 7150361c6c..c4e1e9b12b 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/insights_backfill.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/insights_backfill.sql
@@ -1,11 +1,15 @@
-- Create test user for insights backfill
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', 'test', '[email protected]', 'stripe_test_id');
+
INSERT INTO
- public."User" ("id", "email", "stripeCustomerId")
+ public."User" ("id", "email", "stripeCustomerId", "macro_user_id")
VALUES
(
'test-user-1',
- 'stripe_test_id'
+ 'stripe_test_id',
+ 'a1111111-1111-1111-1111-111111111111'
);
-- Create test insights backfill job
diff --git a/rust/cloud-storage/macro_db_client/fixtures/macro_example.sql b/rust/cloud-storage/macro_db_client/fixtures/macro_example.sql
index df19099da8..853f77053a 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/macro_example.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/macro_example.sql
@@ -1,9 +1,16 @@
--- Insert users
-INSERT INTO public."User" ("id", "email", "stripeCustomerId")
-VALUES ('macro|[email protected]', '[email protected]', 'stripe_id_2');
+-- Insert macro_user entries
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a2222222-2222-2222-2222-222222222222', '[email protected]', '[email protected]', 'stripe_id_2');
-INSERT INTO public."User" ("id", "email", "stripeCustomerId")
-VALUES ('macro|[email protected]', '[email protected]', 'stripe_id');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_id');
+
+-- Insert users
+INSERT INTO public."User" ("id", "email", "stripeCustomerId", "macro_user_id")
+VALUES ('macro|[email protected]', '[email protected]', 'stripe_id_2', 'a2222222-2222-2222-2222-222222222222');
+
+INSERT INTO public."User" ("id", "email", "stripeCustomerId", "macro_user_id")
+VALUES ('macro|[email protected]', '[email protected]', 'stripe_id', 'a1111111-1111-1111-1111-111111111111');
-- Macro Prompts
INSERT INTO public."MacroPrompt" ("id", "title", "prompt", "icon", "color", "required_docs", "user_id", "created_at", "updated_at")
diff --git a/rust/cloud-storage/macro_db_client/fixtures/macrotations.sql b/rust/cloud-storage/macro_db_client/fixtures/macrotations.sql
index 6fa421b5df..817d42d687 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/macrotations.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/macrotations.sql
@@ -1,17 +1,23 @@
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id") VALUES
+ ('a1111111-1111-1111-1111-111111111111', 'user', '[email protected]', 'stripe_id'),
+ ('a2222222-2222-2222-2222-222222222222', 'user2', '[email protected]', 'stripe_id2');
+
INSERT INTO
- public."User" ("id", "email", "stripeCustomerId") (
+ public."User" ("id", "email", "stripeCustomerId", "macro_user_id") (
SELECT
- 'stripe_id'
+ 'stripe_id',
+ 'a1111111-1111-1111-1111-111111111111'
);
INSERT INTO
- public."User" ("id", "email", "stripeCustomerId") (
+ public."User" ("id", "email", "stripeCustomerId", "macro_user_id") (
SELECT
- 'stripe_id2'
+ 'stripe_id2',
+ 'a2222222-2222-2222-2222-222222222222'
);
INSERT INTO
diff --git a/rust/cloud-storage/macro_db_client/fixtures/mixed_items.sql b/rust/cloud-storage/macro_db_client/fixtures/mixed_items.sql
index 69ec0c31c4..427fbdd59d 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/mixed_items.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/mixed_items.sql
@@ -8,14 +8,24 @@ INSERT INTO public."Organization" ("id",
'Test Organization',
'PILOT');
+INSERT INTO public."macro_user" ("id",
+ "username",
+ "email",
+ "stripe_customer_id") (SELECT 'a1111111-1111-1111-1111-111111111111',
+ 'stripe_id');
+
-- Insert user
INSERT INTO public."User" ("id",
"email",
"stripeCustomerId",
- "organizationId") (SELECT 'macro|[email protected]',
+ "organizationId",
+ "macro_user_id") (SELECT 'macro|[email protected]',
'stripe_id',
- 1);
+ 1,
+ 'a1111111-1111-1111-1111-111111111111');
-- Create project
INSERT INTO public."Project" ("id",
diff --git a/rust/cloud-storage/macro_db_client/fixtures/mixed_items_expanded.sql b/rust/cloud-storage/macro_db_client/fixtures/mixed_items_expanded.sql
index 6c6c346ee6..f072d715a0 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/mixed_items_expanded.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/mixed_items_expanded.sql
@@ -10,9 +10,12 @@ INSERT INTO public."Organization" ("id", "name", "status")
VALUES (1, 'Test Organization', 'PILOT')
ON CONFLICT DO NOTHING;
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_id_1');
+
-- Insert user
-INSERT INTO public."User" ("id", "email", "stripeCustomerId", "organizationId")
-VALUES ('macro|[email protected]', '[email protected]', 'stripe_id_1', 1)
+INSERT INTO public."User" ("id", "email", "stripeCustomerId", "organizationId", "macro_user_id")
+VALUES ('macro|[email protected]', '[email protected]', 'stripe_id_1', 1, 'a1111111-1111-1111-1111-111111111111')
ON CONFLICT DO NOTHING;
---------------------------------
diff --git a/rust/cloud-storage/macro_db_client/fixtures/mixed_items_unexpanded.sql b/rust/cloud-storage/macro_db_client/fixtures/mixed_items_unexpanded.sql
index 0df9904650..628291a418 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/mixed_items_unexpanded.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/mixed_items_unexpanded.sql
@@ -12,8 +12,12 @@ SET session_replication_role = 'replica';
INSERT INTO public."Organization" ("id", "name", "status")
VALUES (1, 'Test Org', 'PILOT')
ON CONFLICT DO NOTHING;
-INSERT INTO public."User" ("id", "email", "stripeCustomerId", "organizationId")
-VALUES ('macro|[email protected]', '[email protected]', 'stripe_id', 1);
+
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_id');
+
+INSERT INTO public."User" ("id", "email", "stripeCustomerId", "organizationId", "macro_user_id")
+VALUES ('macro|[email protected]', '[email protected]', 'stripe_id', 1, 'a1111111-1111-1111-1111-111111111111');
-- Item Creation with distinct timestamp orders
-- Project: Newest created, Oldest updated, Middle viewed
diff --git a/rust/cloud-storage/macro_db_client/fixtures/mixed_items_unexpanded_history.sql b/rust/cloud-storage/macro_db_client/fixtures/mixed_items_unexpanded_history.sql
index 2260b44c2b..4b48eb0ec9 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/mixed_items_unexpanded_history.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/mixed_items_unexpanded_history.sql
@@ -10,8 +10,12 @@ SET session_replication_role = 'replica';
INSERT INTO public."Organization" ("id", "name", "status")
VALUES (1, 'Test Organization', 'PILOT')
ON CONFLICT DO NOTHING;
-INSERT INTO public."User" ("id", "email", "stripeCustomerId", "organizationId")
-VALUES ('macro|[email protected]', '[email protected]', 'stripe_id', 1)
+
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_id');
+
+INSERT INTO public."User" ("id", "email", "stripeCustomerId", "organizationId", "macro_user_id")
+VALUES ('macro|[email protected]', '[email protected]', 'stripe_id', 1, 'a1111111-1111-1111-1111-111111111111')
ON CONFLICT DO NOTHING;
INSERT INTO public."Project" ("id", "name", "userId", "createdAt", "updatedAt")
VALUES ('ffffffff-ffff-ffff-ffff-ffffffffffff', 'Test Project', 'macro|[email protected]', '2023-01-17 12:00:00', '2023-01-17 12:00:00');
diff --git a/rust/cloud-storage/macro_db_client/fixtures/nested_share_permissions.sql b/rust/cloud-storage/macro_db_client/fixtures/nested_share_permissions.sql
index 91ef9d0e64..e1cc624b4f 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/nested_share_permissions.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/nested_share_permissions.sql
@@ -1,7 +1,11 @@
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-VALUES
-('macro|[email protected]', '[email protected]','stripe_id'),
-('macro|[email protected]', '[email protected]','stripe_id2');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_id'),
+ ('a2222222-2222-2222-2222-222222222222', '[email protected]', '[email protected]', 'stripe_id2');
+
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+VALUES
+('macro|[email protected]', '[email protected]','stripe_id', 'a1111111-1111-1111-1111-111111111111'),
+('macro|[email protected]', '[email protected]','stripe_id2', 'a2222222-2222-2222-2222-222222222222');
-- Make projects
diff --git a/rust/cloud-storage/macro_db_client/fixtures/no_frecency_items.sql b/rust/cloud-storage/macro_db_client/fixtures/no_frecency_items.sql
index 66c3159b79..ba8abbb7eb 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/no_frecency_items.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/no_frecency_items.sql
@@ -8,8 +8,10 @@ SET session_replication_role = 'replica';
INSERT INTO public."Organization" ("id", "name", "status")
VALUES (1, 'Test Org', 'PILOT')
ON CONFLICT DO NOTHING;
-INSERT INTO public."User" ("id", "email", "stripeCustomerId", "organizationId")
-VALUES ('macro|[email protected]', '[email protected]', 'stripe_id_1', '1');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_id_1');
+INSERT INTO public."User" ("id", "email", "stripeCustomerId", "organizationId", "macro_user_id")
+VALUES ('macro|[email protected]', '[email protected]', 'stripe_id_1', '1', 'a1111111-1111-1111-1111-111111111111');
-- Project Hierarchy
INSERT INTO public."Project" ("id", "name", "userId", "createdAt", "updatedAt")
diff --git a/rust/cloud-storage/macro_db_client/fixtures/no_frecency_items_unexpanded.sql b/rust/cloud-storage/macro_db_client/fixtures/no_frecency_items_unexpanded.sql
index 50ccca7776..fa4994a8da 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/no_frecency_items_unexpanded.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/no_frecency_items_unexpanded.sql
@@ -8,8 +8,12 @@ SET session_replication_role = 'replica';
INSERT INTO public."Organization" ("id", "name", "status")
VALUES (1, 'Test Org', 'PILOT')
ON CONFLICT DO NOTHING;
-INSERT INTO public."User" ("id", "email", "stripeCustomerId", "organizationId")
-VALUES ('macro|[email protected]', '[email protected]', 'stripe_id_1', '1');
+
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_id_1');
+
+INSERT INTO public."User" ("id", "email", "stripeCustomerId", "organizationId", "macro_user_id")
+VALUES ('macro|[email protected]', '[email protected]', 'stripe_id_1', '1', 'a1111111-1111-1111-1111-111111111111');
-- Create documents (2 with frecency, 2 without)
-- Documents WITH frecency (should be filtered out)
diff --git a/rust/cloud-storage/macro_db_client/fixtures/populate_user_items.sql b/rust/cloud-storage/macro_db_client/fixtures/populate_user_items.sql
index 13808d868d..f47a934783 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/populate_user_items.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/populate_user_items.sql
@@ -1,14 +1,19 @@
INSERT INTO public."Organization" ("id","name")
(SELECT 1, 'organization-one');
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id');
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id2');
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id3');
-INSERT INTO public."User" ("id","email","stripeCustomerId", "organizationId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id5', 1);
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', 'user', '[email protected]', 'stripe_id'),
+ ('a2222222-2222-2222-2222-222222222222', 'user2', '[email protected]', 'stripe_id2'),
+ ('a3333333-3333-3333-3333-333333333333', 'user3', '[email protected]', 'stripe_id3'),
+ ('a5555555-5555-5555-5555-555555555555', 'user5', '[email protected]', 'stripe_id5');
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id', 'a1111111-1111-1111-1111-111111111111');
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id2', 'a2222222-2222-2222-2222-222222222222');
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id3', 'a3333333-3333-3333-3333-333333333333');
+INSERT INTO public."User" ("id","email","stripeCustomerId", "organizationId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id5', 1, 'a5555555-5555-5555-5555-555555555555');
INSERT INTO public."Project" ("id", "name", "userId", "createdAt", "updatedAt")
(SELECT 'p1', 'a', 'macro|[email protected]', '2019-10-16 00:00:00', '2019-10-16 00:00:00');
diff --git a/rust/cloud-storage/macro_db_client/fixtures/project-notifications.sql b/rust/cloud-storage/macro_db_client/fixtures/project-notifications.sql
index 190ebfadfe..597bd4728c 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/project-notifications.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/project-notifications.sql
@@ -1,17 +1,23 @@
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id") VALUES
+ ('a1111111-1111-1111-1111-111111111111', 'user', '[email protected]', 'stripe_id'),
+ ('a2222222-2222-2222-2222-222222222222', 'user2', '[email protected]', 'stripe_id2');
+
INSERT INTO
- public."User" ("id", "email", "stripeCustomerId") (
+ public."User" ("id", "email", "stripeCustomerId", "macro_user_id") (
SELECT
- 'stripe_id'
+ 'stripe_id',
+ 'a1111111-1111-1111-1111-111111111111'
);
INSERT INTO
- public."User" ("id", "email", "stripeCustomerId") (
+ public."User" ("id", "email", "stripeCustomerId", "macro_user_id") (
SELECT
- 'stripe_id2'
+ 'stripe_id2',
+ 'a2222222-2222-2222-2222-222222222222'
);
INSERT INTO public."Project" ("id", "name", "userId", "createdAt", "updatedAt")
diff --git a/rust/cloud-storage/macro_db_client/fixtures/project_permissions.sql b/rust/cloud-storage/macro_db_client/fixtures/project_permissions.sql
index cda992dc2d..d1e7a6996c 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/project_permissions.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/project_permissions.sql
@@ -1,8 +1,11 @@
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', 'user', '[email protected]', 'stripe_id'),
+ ('a2222222-2222-2222-2222-222222222222', 'user2', '[email protected]', 'stripe_id2');
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id', 'a1111111-1111-1111-1111-111111111111');
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id2');
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id2', 'a2222222-2222-2222-2222-222222222222');
INSERT INTO public."Project" ("id","name","userId","parentId","createdAt","updatedAt")
(SELECT 'project-one', 'test_project_name','macro|[email protected]', NULL, '2019-10-16 00:00:00', '2019-10-16 00:00:00');
diff --git a/rust/cloud-storage/macro_db_client/fixtures/project_preview.sql b/rust/cloud-storage/macro_db_client/fixtures/project_preview.sql
index 7291282fbe..3f47665ab5 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/project_preview.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/project_preview.sql
@@ -1,7 +1,10 @@
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-VALUES ('macro|[email protected]', '[email protected]','stripe_id');
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-VALUES ('macro|[email protected]', '[email protected]','stripe_iddfkjdfkdf');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', 'user', '[email protected]', 'stripe_id'),
+ ('a2222222-2222-2222-2222-222222222222', 'other', '[email protected]', 'stripe_iddfkjdfkdf');
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+VALUES ('macro|[email protected]', '[email protected]','stripe_id', 'a1111111-1111-1111-1111-111111111111');
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+VALUES ('macro|[email protected]', '[email protected]','stripe_iddfkjdfkdf', 'a2222222-2222-2222-2222-222222222222');
INSERT INTO public."Project" ("id","name", "userId", "createdAt", "updatedAt")
VALUES ('project-one', 'test_project_name', 'macro|[email protected]', '2019-10-16 00:00:00', '2019-10-16 00:00:00');
diff --git a/rust/cloud-storage/macro_db_client/fixtures/project_preview_nested.sql b/rust/cloud-storage/macro_db_client/fixtures/project_preview_nested.sql
index 8ad29d54ab..5f85b9bc14 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/project_preview_nested.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/project_preview_nested.sql
@@ -1,5 +1,7 @@
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-VALUES ('macro|[email protected]', '[email protected]','stripe_id');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', 'user', '[email protected]', 'stripe_id');
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+VALUES ('macro|[email protected]', '[email protected]','stripe_id', 'a1111111-1111-1111-1111-111111111111');
-- Create a nested project hierarchy: Root -> Level1 -> Level2 -> Level3
INSERT INTO public."Project" ("id","name", "userId", "parentId", "createdAt", "updatedAt")
diff --git a/rust/cloud-storage/macro_db_client/fixtures/recently_deleted.sql b/rust/cloud-storage/macro_db_client/fixtures/recently_deleted.sql
index 5742bcc60b..a1e374a1a8 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/recently_deleted.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/recently_deleted.sql
@@ -1,5 +1,8 @@
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+(SELECT 'a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_id');
+
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id', 'a1111111-1111-1111-1111-111111111111');
INSERT INTO public."Project" ("id", "name", "userId", "deletedAt")
(SELECT 'p1', 'a', 'macro|[email protected]', '2019-10-16 00:00:00');
diff --git a/rust/cloud-storage/macro_db_client/fixtures/revert_project_delete.sql b/rust/cloud-storage/macro_db_client/fixtures/revert_project_delete.sql
index f9a9be4df3..8e7ef48ad1 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/revert_project_delete.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/revert_project_delete.sql
@@ -1,8 +1,12 @@
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_id'),
+ ('a2222222-2222-2222-2222-222222222222', '[email protected]', '[email protected]', 'stripe_id2');
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id2');
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id', 'a1111111-1111-1111-1111-111111111111');
+
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id2', 'a2222222-2222-2222-2222-222222222222');
-- Should have user history for user
INSERT INTO public."Project" ("id", "name", "userId", "deletedAt")
diff --git a/rust/cloud-storage/macro_db_client/fixtures/share_permissions.sql b/rust/cloud-storage/macro_db_client/fixtures/share_permissions.sql
index 265e4e2984..6228a9a7be 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/share_permissions.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/share_permissions.sql
@@ -1,7 +1,10 @@
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id');
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id2');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', 'user', '[email protected]', 'stripe_id'),
+ ('a2222222-2222-2222-2222-222222222222', 'user2', '[email protected]', 'stripe_id2');
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id', 'a1111111-1111-1111-1111-111111111111');
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id2', 'a2222222-2222-2222-2222-222222222222');
INSERT INTO public."Document" ("id","name","fileType", "owner", "createdAt", "updatedAt")
(SELECT 'document-one', 'test_document_name','pdf', 'macro|[email protected]', '2019-10-16 00:00:00', '2019-10-16 00:00:00');
diff --git a/rust/cloud-storage/macro_db_client/fixtures/simple_history.sql b/rust/cloud-storage/macro_db_client/fixtures/simple_history.sql
index b2023d7120..50df55b456 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/simple_history.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/simple_history.sql
@@ -1,9 +1,13 @@
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', 'user', '[email protected]', 'stripe_id');
+
INSERT INTO
- public."User" ("id", "email", "stripeCustomerId") (
+ public."User" ("id", "email", "stripeCustomerId", "macro_user_id") (
SELECT
- 'stripe_id'
+ 'stripe_id',
+ 'a1111111-1111-1111-1111-111111111111'
);
INSERT INTO
diff --git a/rust/cloud-storage/macro_db_client/fixtures/simple_items.sql b/rust/cloud-storage/macro_db_client/fixtures/simple_items.sql
index b4b8ecc75d..18307fe360 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/simple_items.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/simple_items.sql
@@ -9,8 +9,11 @@
-- Disable foreign key constraints temporarily
SET session_replication_role = 'replica';
-INSERT INTO public."User" ("id", "email", "stripeCustomerId")
-VALUES ('macro|[email protected]', '[email protected]', 'stripe_id');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_id');
+
+INSERT INTO public."User" ("id", "email", "stripeCustomerId", "macro_user_id")
+VALUES ('macro|[email protected]', '[email protected]', 'stripe_id', 'a1111111-1111-1111-1111-111111111111');
-- Document A: Oldest created, middle updated, newest viewed
INSERT INTO public."Document" ("id", "name", "fileType", "owner", "createdAt", "updatedAt")
diff --git a/rust/cloud-storage/macro_db_client/fixtures/sorting_expanded_items.sql b/rust/cloud-storage/macro_db_client/fixtures/sorting_expanded_items.sql
index 0456a7045d..284adccb90 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/sorting_expanded_items.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/sorting_expanded_items.sql
@@ -14,8 +14,12 @@ SET session_replication_role = 'replica';
INSERT INTO public."Organization" ("id", "name", "status")
VALUES (1, 'Test Org', 'PILOT')
ON CONFLICT DO NOTHING;
-INSERT INTO public."User" ("id", "email", "stripeCustomerId", "organizationId")
-VALUES ('macro|[email protected]', '[email protected]', 'stripe_id_1', '1');
+
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_id_1');
+
+INSERT INTO public."User" ("id", "email", "stripeCustomerId", "organizationId", "macro_user_id")
+VALUES ('macro|[email protected]', '[email protected]', 'stripe_id_1', '1', 'a1111111-1111-1111-1111-111111111111');
-- Project Hierarchy (A -> B)
INSERT INTO public."Project" ("id", "name", "userId", "parentId", "createdAt", "updatedAt")
diff --git a/rust/cloud-storage/macro_db_client/fixtures/soup_items_with_properties.sql b/rust/cloud-storage/macro_db_client/fixtures/soup_items_with_properties.sql
index e8f0e71054..d73aaa0525 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/soup_items_with_properties.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/soup_items_with_properties.sql
@@ -11,9 +11,13 @@ INSERT INTO public."Organization" ("id", "name", "status")
VALUES (1, 'Test Organization', 'PILOT')
ON CONFLICT DO NOTHING;
+-- Insert macro_user
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_id_1');
+
-- Insert user
-INSERT INTO public."User" ("id", "email", "stripeCustomerId", "organizationId")
-VALUES ('macro|[email protected]', '[email protected]', 'stripe_id_1', 1)
+INSERT INTO public."User" ("id", "email", "stripeCustomerId", "organizationId", "macro_user_id")
+VALUES ('macro|[email protected]', '[email protected]', 'stripe_id_1', 1, 'a1111111-1111-1111-1111-111111111111')
ON CONFLICT DO NOTHING;
---------------------------------
diff --git a/rust/cloud-storage/macro_db_client/fixtures/tasks_with_is_completed.sql b/rust/cloud-storage/macro_db_client/fixtures/tasks_with_is_completed.sql
index d39c0f0d29..ceeec761b8 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/tasks_with_is_completed.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/tasks_with_is_completed.sql
@@ -10,8 +10,11 @@
-- Disable foreign key constraints temporarily
SET session_replication_role = 'replica';
-INSERT INTO public."User" ("id", "email", "stripeCustomerId")
-VALUES ('macro|[email protected]', '[email protected]', 'stripe_id');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_id');
+
+INSERT INTO public."User" ("id", "email", "stripeCustomerId", "macro_user_id")
+VALUES ('macro|[email protected]', '[email protected]', 'stripe_id', 'a1111111-1111-1111-1111-111111111111');
-- Task with Status = "Completed"
INSERT INTO public."Document" ("id", "name", "fileType", "owner", "createdAt", "updatedAt")
diff --git a/rust/cloud-storage/macro_db_client/fixtures/team.sql b/rust/cloud-storage/macro_db_client/fixtures/team.sql
index 2602684bc8..150e491438 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/team.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/team.sql
@@ -1,8 +1,13 @@
-INSERT INTO "User" (id, email)
+INSERT INTO "macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', 'test', '[email protected]', 'stripe_test'),
+ ('a2222222-2222-2222-2222-222222222222', 'test2', '[email protected]', 'stripe_test2'),
+ ('a3333333-3333-3333-3333-333333333333', 'test3', '[email protected]', 'stripe_test3'),
+ ('a4444444-4444-4444-4444-444444444444', 'test4', '[email protected]', 'stripe_test4');
+INSERT INTO "User" (id, email, macro_user_id)
+VALUES ('macro|[email protected]', '[email protected]', 'a1111111-1111-1111-1111-111111111111'),
+ ('macro|[email protected]', '[email protected]', 'a2222222-2222-2222-2222-222222222222'),
+ ('macro|[email protected]', '[email protected]', 'a3333333-3333-3333-3333-333333333333'),
+ ('macro|[email protected]', '[email protected]', 'a4444444-4444-4444-4444-444444444444');
INSERT INTO team (id, name, owner_id)
VALUES ('11111111-1111-1111-1111-111111111111', 'team1', 'macro|[email protected]');
diff --git a/rust/cloud-storage/macro_db_client/fixtures/uia_access_level_chat.sql b/rust/cloud-storage/macro_db_client/fixtures/uia_access_level_chat.sql
index 8c261e39be..22a9f71330 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/uia_access_level_chat.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/uia_access_level_chat.sql
@@ -1,7 +1,10 @@
-- Create two users for testing user-scoping.
-INSERT INTO public."User" ("id", "email")
-VALUES ('user-1', '[email protected]'),
- ('user-2', '[email protected]');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', 'user1', '[email protected]', 'stripe_user1'),
+ ('a2222222-2222-2222-2222-222222222222', 'user2', '[email protected]', 'stripe_user2');
+INSERT INTO public."User" ("id", "email", "macro_user_id")
+VALUES ('user-1', '[email protected]', 'a1111111-1111-1111-1111-111111111111'),
+ ('user-2', '[email protected]', 'a2222222-2222-2222-2222-222222222222');
-- Create a nested project hierarchy: p-grandparent -> p-parent.
INSERT INTO public."Project" ("id", "name", "userId", "parentId")
diff --git a/rust/cloud-storage/macro_db_client/fixtures/uia_access_level_doc.sql b/rust/cloud-storage/macro_db_client/fixtures/uia_access_level_doc.sql
index 2ac7d92dc5..f7ab10522b 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/uia_access_level_doc.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/uia_access_level_doc.sql
@@ -1,9 +1,13 @@
-- Create two users.
-- 'user-1' is the primary user we will test against.
-- 'user-2' has some overlapping permissions to ensure our queries correctly filter by user.
-INSERT INTO public."User" ("id", "email")
-VALUES ('user-1', '[email protected]'),
- ('user-2', '[email protected]');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_user1'),
+ ('a2222222-2222-2222-2222-222222222222', '[email protected]', '[email protected]', 'stripe_user2');
+
+INSERT INTO public."User" ("id", "email", "macro_user_id")
+VALUES ('user-1', '[email protected]', 'a1111111-1111-1111-1111-111111111111'),
+ ('user-2', '[email protected]', 'a2222222-2222-2222-2222-222222222222');
-- Create a nested project hierarchy: p-grandparent -> p-parent.
-- Also create an unrelated project to ensure it's not picked up by the query.
diff --git a/rust/cloud-storage/macro_db_client/fixtures/uia_access_level_project.sql b/rust/cloud-storage/macro_db_client/fixtures/uia_access_level_project.sql
index 2531582b85..5d9842040f 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/uia_access_level_project.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/uia_access_level_project.sql
@@ -1,7 +1,12 @@
+-- Create macro_user records.
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_user1'),
+ ('a2222222-2222-2222-2222-222222222222', '[email protected]', '[email protected]', 'stripe_user2');
+
-- Create two users for testing user-scoping.
-INSERT INTO public."User" ("id", "email")
-VALUES ('user-1', '[email protected]'),
- ('user-2', '[email protected]');
+INSERT INTO public."User" ("id", "email", "macro_user_id")
+VALUES ('user-1', '[email protected]', 'a1111111-1111-1111-1111-111111111111'),
+ ('user-2', '[email protected]', 'a2222222-2222-2222-2222-222222222222');
-- Create a nested project hierarchy: p-grandparent -> p-parent -> p-child.
-- Also create an isolated project for the "no access" test case.
diff --git a/rust/cloud-storage/macro_db_client/fixtures/uia_access_level_thread.sql b/rust/cloud-storage/macro_db_client/fixtures/uia_access_level_thread.sql
index acf12dfaaf..8aaf6dd4b0 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/uia_access_level_thread.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/uia_access_level_thread.sql
@@ -1,7 +1,12 @@
+-- Create macro_user records.
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_user1'),
+ ('a2222222-2222-2222-2222-222222222222', '[email protected]', '[email protected]', 'stripe_user2');
+
-- Create two users for testing user-scoping.
-INSERT INTO public."User" ("id", "email")
-VALUES ('user-1', '[email protected]'),
- ('user-2', '[email protected]');
+INSERT INTO public."User" ("id", "email", "macro_user_id")
+VALUES ('user-1', '[email protected]', 'a1111111-1111-1111-1111-111111111111'),
+ ('user-2', '[email protected]', 'a2222222-2222-2222-2222-222222222222');
-- Create a nested project hierarchy: p-grandparent -> p-parent.
INSERT INTO public."Project" ("id", "name", "userId", "parentId")
diff --git a/rust/cloud-storage/macro_db_client/fixtures/update_legacy_user.sql b/rust/cloud-storage/macro_db_client/fixtures/update_legacy_user.sql
index 2479e0924b..7011313e8d 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/update_legacy_user.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/update_legacy_user.sql
@@ -1,6 +1,9 @@
-INSERT INTO "User" ("id", "email", "name", "stripeCustomerId") VALUES
-('legacy|[email protected]', '[email protected]', 'User', 'cus_1234'),
-('legacy|[email protected]', '[email protected]', 'User2', 'cus_12345');
+INSERT INTO "macro_user" ("id", "username", "email", "stripe_customer_id") VALUES
+('a1111111-1111-1111-1111-111111111111', 'user', '[email protected]', 'cus_1234'),
+('a2222222-2222-2222-2222-222222222222', 'user2', '[email protected]', 'cus_12345');
+INSERT INTO "User" ("id", "email", "name", "stripeCustomerId", "macro_user_id") VALUES
+('legacy|[email protected]', '[email protected]', 'User', 'cus_1234', 'a1111111-1111-1111-1111-111111111111'),
+('legacy|[email protected]', '[email protected]', 'User2', 'cus_12345', 'a2222222-2222-2222-2222-222222222222');
INSERT INTO "Role" ("id", "description") VALUES
('role-one', 'Role One'),
diff --git a/rust/cloud-storage/macro_db_client/fixtures/user_history.sql b/rust/cloud-storage/macro_db_client/fixtures/user_history.sql
index 45fb2611b3..227e3f0cfb 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/user_history.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/user_history.sql
@@ -1,14 +1,20 @@
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_id'),
+ ('a2222222-2222-2222-2222-222222222222', '[email protected]', '[email protected]', 'stripe_id2'),
+ ('a3333333-3333-3333-3333-333333333333', '[email protected]', '[email protected]', 'stripe_id3'),
+ ('a4444444-4444-4444-4444-444444444444', '[email protected]', '[email protected]', 'stripe_id4');
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id2');
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id', 'a1111111-1111-1111-1111-111111111111');
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id3');
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id2', 'a2222222-2222-2222-2222-222222222222');
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id4');
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id3', 'a3333333-3333-3333-3333-333333333333');
+
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id4', 'a4444444-4444-4444-4444-444444444444');
INSERT INTO public."Document" ("id","name","fileType", "owner", "createdAt", "updatedAt")
(SELECT 'document-one', 'test_document_name','pdf', 'macro|[email protected]', '2019-10-16 00:00:00', '2019-10-16 00:00:00');
diff --git a/rust/cloud-storage/macro_db_client/fixtures/user_item_access.sql b/rust/cloud-storage/macro_db_client/fixtures/user_item_access.sql
index 0ef73efaa0..b6a7c032d9 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/user_item_access.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/user_item_access.sql
@@ -1,20 +1,27 @@
INSERT INTO public."Organization" ("id", "name")
(SELECT 1, 'organization-one');
-INSERT INTO public."User" ("id", "email", "stripeCustomerId", "organizationId")
- (SELECT 'macro|[email protected]', '[email protected]', 'stripe_id', 1);
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_id'),
+ ('a2222222-2222-2222-2222-222222222222', '[email protected]', '[email protected]', 'stripe_id2'),
+ ('a3333333-3333-3333-3333-333333333333', '[email protected]', '[email protected]', 'stripe_id3'),
+ ('a4444444-4444-4444-4444-444444444444', '[email protected]', '[email protected]', 'stripe_id4'),
+ ('a5555555-5555-5555-5555-555555555555', '[email protected]', '[email protected]', 'stripe_id5');
-INSERT INTO public."User" ("id", "email", "stripeCustomerId", "organizationId")
- (SELECT 'macro|[email protected]', '[email protected]', 'stripe_id2', 1);
+INSERT INTO public."User" ("id", "email", "stripeCustomerId", "organizationId", "macro_user_id")
+ (SELECT 'macro|[email protected]', '[email protected]', 'stripe_id', 1, 'a1111111-1111-1111-1111-111111111111');
-INSERT INTO public."User" ("id", "email", "stripeCustomerId", "organizationId")
- (SELECT 'macro|[email protected]', '[email protected]', 'stripe_id3', 1);
+INSERT INTO public."User" ("id", "email", "stripeCustomerId", "organizationId", "macro_user_id")
+ (SELECT 'macro|[email protected]', '[email protected]', 'stripe_id2', 1, 'a2222222-2222-2222-2222-222222222222');
-INSERT INTO public."User" ("id", "email", "stripeCustomerId")
- (SELECT 'macro|[email protected]', '[email protected]', 'stripe_id4');
+INSERT INTO public."User" ("id", "email", "stripeCustomerId", "organizationId", "macro_user_id")
+ (SELECT 'macro|[email protected]', '[email protected]', 'stripe_id3', 1, 'a3333333-3333-3333-3333-333333333333');
-INSERT INTO public."User" ("id", "email", "stripeCustomerId")
- (SELECT 'macro|[email protected]', '[email protected]', 'stripe_id5');
+INSERT INTO public."User" ("id", "email", "stripeCustomerId", "macro_user_id")
+ (SELECT 'macro|[email protected]', '[email protected]', 'stripe_id4', 'a4444444-4444-4444-4444-444444444444');
+
+INSERT INTO public."User" ("id", "email", "stripeCustomerId", "macro_user_id")
+ (SELECT 'macro|[email protected]', '[email protected]', 'stripe_id5', 'a5555555-5555-5555-5555-555555555555');
INSERT INTO public."Document" ("id", "name", "fileType", "owner", "createdAt", "updatedAt")
(SELECT 'document-one',
@@ -41,15 +48,26 @@ INSERT INTO public."Document" ("id", "name", "fileType", "owner", "createdAt", "
INSERT INTO public."DocumentInstance" ("revisionName", "documentId", "createdAt", "updatedAt", "sha")
(SELECT 'test_document_name', 'document-two', '2019-10-16 00:00:00', '2019-10-16 00:00:00', 'sha');
+-- Create macro_user records for test users
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+VALUES ('a6666666-6666-6666-6666-666666666666', 'test-user', '[email protected]', 'stripe_test-user'),
+ ('a7777777-7777-7777-7777-777777777777', 'user0', '[email protected]', 'stripe_user0'),
+ ('a8888888-8888-8888-8888-888888888888', 'uia_user1', '[email protected]', 'stripe_uia_user1'),
+ ('a9999999-9999-9999-9999-999999999999', 'uia_user2', '[email protected]', 'stripe_uia_user2'),
+ ('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'uia_user3', '[email protected]', 'stripe_uia_user3'),
+ ('abbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb', 'uia_user4', '[email protected]', 'stripe_uia_user4'),
+ ('accccccc-cccc-cccc-cccc-cccccccccccc', 'uia_user5', '[email protected]', 'stripe_uia_user5')
+ON CONFLICT (id) DO NOTHING;
+
-- Create test users needed for all UserItemAccess tests
-INSERT INTO public."User" ("id", "email")
+INSERT INTO public."User" ("id", "email", "macro_user_id")
+VALUES ('macro|[email protected]', '[email protected]', 'a6666666-6666-6666-6666-666666666666'),
+ ('macro|[email protected]', '[email protected]', 'a7777777-7777-7777-7777-777777777777'),
+ ('macro|[email protected]', '[email protected]', 'a8888888-8888-8888-8888-888888888888'),
+ ('macro|[email protected]', '[email protected]', 'a9999999-9999-9999-9999-999999999999'),
+ ('macro|[email protected]', '[email protected]', 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'),
+ ('macro|[email protected]', '[email protected]', 'abbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb'),
+ ('macro|[email protected]', '[email protected]', 'accccccc-cccc-cccc-cccc-cccccccccccc')
ON CONFLICT (id) DO NOTHING;
-- Create single user item access record for test_delete_user_item_access
diff --git a/rust/cloud-storage/macro_db_client/fixtures/user_names_with_email.sql b/rust/cloud-storage/macro_db_client/fixtures/user_names_with_email.sql
index ae16dcd82d..181a712039 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/user_names_with_email.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/user_names_with_email.sql
@@ -7,7 +7,8 @@ VALUES
('22222222-2222-2222-2222-222222222222', 'test_user_2', '[email protected]', 'cus_test2'),
('33333333-3333-3333-3333-333333333333', 'test_user_3', '[email protected]', 'cus_test3'),
('44444444-4444-4444-4444-444444444444', 'test_user_4', '[email protected]', 'cus_test4'),
- ('55555555-5555-5555-5555-555555555555', 'test_user_5', '[email protected]', 'cus_test5');
+ ('55555555-5555-5555-5555-555555555555', 'test_user_5', '[email protected]', 'cus_test5'),
+ ('66666666-6666-6666-6666-666666666666', 'contact', '[email protected]', 'cus_test6');
-- Create macro user info with names
INSERT INTO macro_user_info (macro_user_id, first_name, last_name)
@@ -26,7 +27,7 @@ VALUES
('macro|[email protected]', '[email protected]', '33333333-3333-3333-3333-333333333333', NULL, false, false, false),
('macro|[email protected]', '[email protected]', '44444444-4444-4444-4444-444444444444', NULL, false, false, false),
('macro|[email protected]', '[email protected]', '55555555-5555-5555-5555-555555555555', NULL, false, false, false),
- ('macro|[email protected]', '[email protected]', NULL, NULL, false, false, false);
+ ('macro|[email protected]', '[email protected]', '66666666-6666-6666-6666-666666666666', NULL, false, false, false);
-- Create email link for macro user 1 (for email contacts lookup)
INSERT INTO email_links (id, macro_id, fusionauth_user_id, email_address, provider, is_sync_active)
diff --git a/rust/cloud-storage/macro_db_client/fixtures/user_quota.sql b/rust/cloud-storage/macro_db_client/fixtures/user_quota.sql
index d26109b252..2c65e52202 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/user_quota.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/user_quota.sql
@@ -1,6 +1,9 @@
-INSERT INTO "User" ("id", "email", "name", "stripeCustomerId") VALUES
-('macro|[email protected]', '[email protected]', 'User', 'cus_1234'),
-('macro|[email protected]', '[email protected]', 'User2', 'cus_12345');
+INSERT INTO "macro_user" ("id", "username", "email", "stripe_customer_id") VALUES
+('a1111111-1111-1111-1111-111111111111', 'user', '[email protected]', 'cus_1234'),
+('a2222222-2222-2222-2222-222222222222', 'user2', '[email protected]', 'cus_12345');
+INSERT INTO "User" ("id", "email", "name", "stripeCustomerId", "macro_user_id") VALUES
+('macro|[email protected]', '[email protected]', 'User', 'cus_1234', 'a1111111-1111-1111-1111-111111111111'),
+('macro|[email protected]', '[email protected]', 'User2', 'cus_12345', 'a2222222-2222-2222-2222-222222222222');
INSERT INTO "RolesOnUsers" ("userId", "roleId") VALUES
('macro|[email protected]', 'professional_subscriber'),
diff --git a/rust/cloud-storage/macro_db_client/fixtures/users.sql b/rust/cloud-storage/macro_db_client/fixtures/users.sql
index 0da21d9b17..1b7b790173 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/users.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/users.sql
@@ -1,11 +1,20 @@
INSERT INTO public."Organization" ("id","name")
(SELECT 1, 'organization-one');
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id');
-INSERT INTO public."User" ("id","email","stripeCustomerId", "hasOnboardingDocuments")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id2', TRUE);
-INSERT INTO public."User" ("id","email","stripeCustomerId", "organizationId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id3', 1);
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id5');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+(SELECT 'a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_id');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+(SELECT 'a2222222-2222-2222-2222-222222222222', '[email protected]', '[email protected]', 'stripe_id2');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+(SELECT 'a3333333-3333-3333-3333-333333333333', '[email protected]', '[email protected]', 'stripe_id3');
+INSERT INTO public."macro_user" ("id", "username", "email", "stripe_customer_id")
+(SELECT 'a5555555-5555-5555-5555-555555555555', '[email protected]', '[email protected]', 'stripe_id5');
+
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id', 'a1111111-1111-1111-1111-111111111111');
+INSERT INTO public."User" ("id","email","stripeCustomerId", "hasOnboardingDocuments","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id2', TRUE, 'a2222222-2222-2222-2222-222222222222');
+INSERT INTO public."User" ("id","email","stripeCustomerId", "organizationId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id3', 1, 'a3333333-3333-3333-3333-333333333333');
+INSERT INTO public."User" ("id","email","stripeCustomerId","macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id5', 'a5555555-5555-5555-5555-555555555555');
diff --git a/rust/cloud-storage/macro_db_client/migrations/20260317134451_remove_nullable_macro_user_id.sql b/rust/cloud-storage/macro_db_client/migrations/20260317134451_remove_nullable_macro_user_id.sql
new file mode 100644
index 0000000000..4a1f75562a
--- /dev/null
+++ b/rust/cloud-storage/macro_db_client/migrations/20260317134451_remove_nullable_macro_user_id.sql
@@ -0,0 +1,2 @@
+-- Add migration script here
+ALTER TABLE "User" ALTER COLUMN macro_user_id SET NOT NULL;
diff --git a/rust/cloud-storage/macro_db_client/src/projects/upload_folder/mod.rs b/rust/cloud-storage/macro_db_client/src/projects/upload_folder/mod.rs
index 28c604e3fa..ddbf2f4e4b 100644
--- a/rust/cloud-storage/macro_db_client/src/projects/upload_folder/mod.rs
+++ b/rust/cloud-storage/macro_db_client/src/projects/upload_folder/mod.rs
@@ -274,15 +274,32 @@ mod tests {
use uuid::Uuid;
async fn create_test_permission(pool: &Pool<Postgres>) -> anyhow::Result<SharePermissionV2> {
+ let macro_user_id = Uuid::new_v4();
+
+ // insert macro_user first (foreign key for User.macro_user_id)
+ sqlx::query!(
+ r#"
+ INSERT INTO "macro_user" ("id", "username", "email", "stripe_customer_id")
+ VALUES ($1, $2, $3, $4)
+ "#,
+ macro_user_id,
+ "stripe_id"
+ )
+ .execute(pool)
+ .await?;
+
// insert macro user into user table
let _user = sqlx::query!(
r#"
- INSERT INTO "User" ("id", "email")
- VALUES ($1, $2)
+ INSERT INTO "User" ("id", "email", "macro_user_id")
+ VALUES ($1, $2, $3)
RETURNING id
"#,
+ macro_user_id
)
.fetch_one(pool)
.await?;
diff --git a/rust/cloud-storage/name_search/fixtures/chat.sql b/rust/cloud-storage/name_search/fixtures/chat.sql
index 361a7945fd..7c3fca6cd8 100644
--- a/rust/cloud-storage/name_search/fixtures/chat.sql
+++ b/rust/cloud-storage/name_search/fixtures/chat.sql
@@ -1,9 +1,16 @@
+-- Test macro_users
+INSERT INTO "macro_user" (id, username, email, stripe_customer_id)
+VALUES
+ ('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_user1'),
+ ('a2222222-2222-2222-2222-222222222222', '[email protected]', '[email protected]', 'stripe_user2'),
+ ('a3333333-3333-3333-3333-333333333333', '[email protected]', '[email protected]', 'stripe_user3');
+
-- Test users
-INSERT INTO "User" (id, email, name)
+INSERT INTO "User" (id, email, name, macro_user_id)
VALUES
- ('macro|[email protected]', '[email protected]', 'Test User 1'),
- ('macro|[email protected]', '[email protected]', 'Test User 2'),
- ('macro|[email protected]', '[email protected]', 'Test User 3');
+ ('macro|[email protected]', '[email protected]', 'Test User 1', 'a1111111-1111-1111-1111-111111111111'),
+ ('macro|[email protected]', '[email protected]', 'Test User 2', 'a2222222-2222-2222-2222-222222222222'),
+ ('macro|[email protected]', '[email protected]', 'Test User 3', 'a3333333-3333-3333-3333-333333333333');
-- Test chats for user1 (userId)
INSERT INTO "Chat" (id, name, "userId", "createdAt", "updatedAt", "deletedAt", model, "isPersistent")
diff --git a/rust/cloud-storage/name_search/fixtures/document.sql b/rust/cloud-storage/name_search/fixtures/document.sql
index 14504140b8..3ccf0be5fe 100644
--- a/rust/cloud-storage/name_search/fixtures/document.sql
+++ b/rust/cloud-storage/name_search/fixtures/document.sql
@@ -1,9 +1,16 @@
+-- Test macro_users
+INSERT INTO "macro_user" (id, username, email, stripe_customer_id)
+VALUES
+ ('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_user1'),
+ ('a2222222-2222-2222-2222-222222222222', '[email protected]', '[email protected]', 'stripe_user2'),
+ ('a3333333-3333-3333-3333-333333333333', '[email protected]', '[email protected]', 'stripe_user3');
+
-- Test users
-INSERT INTO "User" (id, email, name)
+INSERT INTO "User" (id, email, name, macro_user_id)
VALUES
- ('macro|[email protected]', '[email protected]', 'Test User 1'),
- ('macro|[email protected]', '[email protected]', 'Test User 2'),
- ('macro|[email protected]', '[email protected]', 'Test User 3');
+ ('macro|[email protected]', '[email protected]', 'Test User 1', 'a1111111-1111-1111-1111-111111111111'),
+ ('macro|[email protected]', '[email protected]', 'Test User 2', 'a2222222-2222-2222-2222-222222222222'),
+ ('macro|[email protected]', '[email protected]', 'Test User 3', 'a3333333-3333-3333-3333-333333333333');
-- Test documents for user1 (owner)
INSERT INTO "Document" (id, name, owner, "fileType", "createdAt", "updatedAt", uploaded)
diff --git a/rust/cloud-storage/name_search/fixtures/email.sql b/rust/cloud-storage/name_search/fixtures/email.sql
index 22d846c2a5..7bbfdefbdd 100644
--- a/rust/cloud-storage/name_search/fixtures/email.sql
+++ b/rust/cloud-storage/name_search/fixtures/email.sql
@@ -1,9 +1,16 @@
+-- Test macro_users
+INSERT INTO "macro_user" (id, username, email, stripe_customer_id)
+VALUES
+ ('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_user1'),
+ ('a2222222-2222-2222-2222-222222222222', '[email protected]', '[email protected]', 'stripe_user2'),
+ ('a3333333-3333-3333-3333-333333333333', '[email protected]', '[email protected]', 'stripe_user3');
+
-- Test users
-INSERT INTO "User" (id, email, name)
+INSERT INTO "User" (id, email, name, macro_user_id)
VALUES
- ('macro|[email protected]', '[email protected]', 'Test User 1'),
- ('macro|[email protected]', '[email protected]', 'Test User 2'),
- ('macro|[email protected]', '[email protected]', 'Test User 3');
+ ('macro|[email protected]', '[email protected]', 'Test User 1', 'a1111111-1111-1111-1111-111111111111'),
+ ('macro|[email protected]', '[email protected]', 'Test User 2', 'a2222222-2222-2222-2222-222222222222'),
+ ('macro|[email protected]', '[email protected]', 'Test User 3', 'a3333333-3333-3333-3333-333333333333');
-- Email links (email account connections for each user)
INSERT INTO email_links (id, macro_id, fusionauth_user_id, email_address, provider, is_sync_active, created_at, updated_at)
diff --git a/rust/cloud-storage/name_search/fixtures/project.sql b/rust/cloud-storage/name_search/fixtures/project.sql
index 5d69d35831..5b7762ca20 100644
--- a/rust/cloud-storage/name_search/fixtures/project.sql
+++ b/rust/cloud-storage/name_search/fixtures/project.sql
@@ -1,9 +1,16 @@
+-- Test macro_users
+INSERT INTO "macro_user" (id, username, email, stripe_customer_id)
+VALUES
+ ('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_user1'),
+ ('a2222222-2222-2222-2222-222222222222', '[email protected]', '[email protected]', 'stripe_user2'),
+ ('a3333333-3333-3333-3333-333333333333', '[email protected]', '[email protected]', 'stripe_user3');
+
-- Test users
-INSERT INTO "User" (id, email, name)
+INSERT INTO "User" (id, email, name, macro_user_id)
VALUES
- ('macro|[email protected]', '[email protected]', 'Test User 1'),
- ('macro|[email protected]', '[email protected]', 'Test User 2'),
- ('macro|[email protected]', '[email protected]', 'Test User 3');
+ ('macro|[email protected]', '[email protected]', 'Test User 1', 'a1111111-1111-1111-1111-111111111111'),
+ ('macro|[email protected]', '[email protected]', 'Test User 2', 'a2222222-2222-2222-2222-222222222222'),
+ ('macro|[email protected]', '[email protected]', 'Test User 3', 'a3333333-3333-3333-3333-333333333333');
-- Test projects for user1 (userId)
INSERT INTO "Project" (id, name, "userId", "createdAt", "updatedAt", "deletedAt")
diff --git a/rust/cloud-storage/organization_retention_handler/fixtures/testing.sql b/rust/cloud-storage/organization_retention_handler/fixtures/testing.sql
index 3f1b3854bb..8efb5f1f1e 100644
--- a/rust/cloud-storage/organization_retention_handler/fixtures/testing.sql
+++ b/rust/cloud-storage/organization_retention_handler/fixtures/testing.sql
@@ -1,11 +1,17 @@
INSERT INTO "Organization" (id, name) VALUES (1, 'test organization');
-INSERT INTO public."User" ("id","email","stripeCustomerId", "organizationId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id', 1);
-INSERT INTO public."User" ("id","email","stripeCustomerId", "organizationId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id2', 1);
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id3');
+INSERT INTO "macro_user" (id, username, email, stripe_customer_id)
+VALUES
+ ('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_id'),
+ ('a2222222-2222-2222-2222-222222222222', '[email protected]', '[email protected]', 'stripe_id2'),
+ ('a3333333-3333-3333-3333-333333333333', '[email protected]', '[email protected]', 'stripe_id3');
+
+INSERT INTO public."User" ("id","email","stripeCustomerId", "organizationId", "macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id', 1, 'a1111111-1111-1111-1111-111111111111');
+INSERT INTO public."User" ("id","email","stripeCustomerId", "organizationId", "macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id2', 1, 'a2222222-2222-2222-2222-222222222222');
+INSERT INTO public."User" ("id","email","stripeCustomerId", "macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id3', 'a3333333-3333-3333-3333-333333333333');
INSERT INTO public."Document" ("id","name","fileType", "owner")
(SELECT 'd1', 'test_document_name','pdf', 'macro|[email protected]');
diff --git a/rust/cloud-storage/organization_retention_handler/migrations/20240325143515_basic_schema_for_testing.sql b/rust/cloud-storage/organization_retention_handler/migrations/20240325143515_basic_schema_for_testing.sql
index 635caf3b05..4e9fb7d428 100644
--- a/rust/cloud-storage/organization_retention_handler/migrations/20240325143515_basic_schema_for_testing.sql
+++ b/rust/cloud-storage/organization_retention_handler/migrations/20240325143515_basic_schema_for_testing.sql
@@ -17,6 +17,14 @@ CREATE TABLE "OrganizationRetentionPolicy"
FOREIGN KEY ("organization_id") REFERENCES "Organization" ("id") ON DELETE CASCADE
);
+CREATE TABLE "macro_user"
+(
+ "id" UUID PRIMARY KEY,
+ "username" TEXT UNIQUE NOT NULL,
+ "email" TEXT UNIQUE NOT NULL,
+ "stripe_customer_id" TEXT UNIQUE NOT NULL
+);
+
CREATE TABLE "User"
(
"id" TEXT PRIMARY KEY,
@@ -24,7 +32,9 @@ CREATE TABLE "User"
"name" TEXT,
"stripeCustomerId" TEXT UNIQUE,
"organizationId" INTEGER,
- FOREIGN KEY ("organizationId") REFERENCES "Organization" ("id") ON DELETE SET NULL
+ "macro_user_id" UUID NOT NULL,
+ FOREIGN KEY ("organizationId") REFERENCES "Organization" ("id") ON DELETE SET NULL,
+ FOREIGN KEY ("macro_user_id") REFERENCES "macro_user" ("id")
);
CREATE TABLE "Permission"
diff --git a/rust/cloud-storage/properties_db_client/fixtures/properties.sql b/rust/cloud-storage/properties_db_client/fixtures/properties.sql
index d93c0e618b..95158a104f 100644
--- a/rust/cloud-storage/properties_db_client/fixtures/properties.sql
+++ b/rust/cloud-storage/properties_db_client/fixtures/properties.sql
@@ -5,10 +5,17 @@ VALUES (1, 'Test Org 1'),
(2, 'Test Org 2')
ON CONFLICT (id) DO NOTHING;
-INSERT INTO "User" (id, email, name, "stripeCustomerId")
-VALUES ('user1', '[email protected]', 'Test User 1', 'cus_test1'),
- ('user2', '[email protected]', 'Test User 2', 'cus_test2'),
- ('user3', '[email protected]', 'Test User 3', 'cus_test3')
+INSERT INTO "macro_user" (id, username, email, stripe_customer_id)
+VALUES
+ ('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'cus_test1'),
+ ('a2222222-2222-2222-2222-222222222222', '[email protected]', '[email protected]', 'cus_test2'),
+ ('a3333333-3333-3333-3333-333333333333', '[email protected]', '[email protected]', 'cus_test3')
+ON CONFLICT (id) DO NOTHING;
+
+INSERT INTO "User" (id, email, name, "stripeCustomerId", macro_user_id)
+VALUES ('user1', '[email protected]', 'Test User 1', 'cus_test1', 'a1111111-1111-1111-1111-111111111111'),
+ ('user2', '[email protected]', 'Test User 2', 'cus_test2', 'a2222222-2222-2222-2222-222222222222'),
+ ('user3', '[email protected]', 'Test User 3', 'cus_test3', 'a3333333-3333-3333-3333-333333333333')
ON CONFLICT (id) DO NOTHING;
-- Property definitions with various data types
diff --git a/rust/cloud-storage/roles_and_permissions/fixtures/users.sql b/rust/cloud-storage/roles_and_permissions/fixtures/users.sql
index ea9c19422f..59c53bb5db 100644
--- a/rust/cloud-storage/roles_and_permissions/fixtures/users.sql
+++ b/rust/cloud-storage/roles_and_permissions/fixtures/users.sql
@@ -1,6 +1,11 @@
-INSERT INTO "User" ("id", "email", "name", "stripeCustomerId") VALUES
-('macro|[email protected]', '[email protected]', 'User', 'cus_1234'),
-('macro|[email protected]', '[email protected]', 'User2', 'cus_12345');
+INSERT INTO "macro_user" (id, username, email, stripe_customer_id)
+VALUES
+ ('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'cus_1234'),
+ ('a2222222-2222-2222-2222-222222222222', '[email protected]', '[email protected]', 'cus_12345');
+
+INSERT INTO "User" ("id", "email", "name", "stripeCustomerId", "macro_user_id") VALUES
+('macro|[email protected]', '[email protected]', 'User', 'cus_1234', 'a1111111-1111-1111-1111-111111111111'),
+('macro|[email protected]', '[email protected]', 'User2', 'cus_12345', 'a2222222-2222-2222-2222-222222222222');
INSERT INTO "RolesOnUsers" ("userId", "roleId") VALUES
('macro|[email protected]', 'professional_subscriber'),
diff --git a/rust/cloud-storage/sha_cleanup_worker/fixtures/shas.sql b/rust/cloud-storage/sha_cleanup_worker/fixtures/shas.sql
index 3ac4be0526..7e1d2e0bff 100644
--- a/rust/cloud-storage/sha_cleanup_worker/fixtures/shas.sql
+++ b/rust/cloud-storage/sha_cleanup_worker/fixtures/shas.sql
@@ -1,5 +1,8 @@
-INSERT INTO public."User" ("id","email","stripeCustomerId")
-(SELECT 'macro|[email protected]', '[email protected]','stripe_id');
+INSERT INTO "macro_user" (id, username, email, stripe_customer_id)
+VALUES ('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'stripe_id');
+
+INSERT INTO public."User" ("id","email","stripeCustomerId", "macro_user_id")
+(SELECT 'macro|[email protected]', '[email protected]','stripe_id', 'a1111111-1111-1111-1111-111111111111');
INSERT INTO public."Document" ("id","name","fileType", "owner", "createdAt", "updatedAt")
(SELECT 'document-one', 'test_document_name','pdf', 'macro|[email protected]', '2019-10-16 00:00:00', '2019-10-16 00:00:00');
diff --git a/rust/cloud-storage/sha_cleanup_worker/migrations/20240325143515_basic_schema_for_testing.sql b/rust/cloud-storage/sha_cleanup_worker/migrations/20240325143515_basic_schema_for_testing.sql
index 2833d4ecb4..97c5f50672 100644
--- a/rust/cloud-storage/sha_cleanup_worker/migrations/20240325143515_basic_schema_for_testing.sql
+++ b/rust/cloud-storage/sha_cleanup_worker/migrations/20240325143515_basic_schema_for_testing.sql
@@ -3,11 +3,20 @@
-- Changes here WILL NOT ever make it into the dev/production db.
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
+CREATE TABLE "macro_user" (
+ "id" UUID PRIMARY KEY,
+ "username" TEXT UNIQUE NOT NULL,
+ "email" TEXT UNIQUE NOT NULL,
+ "stripe_customer_id" TEXT UNIQUE NOT NULL
+);
+
CREATE TABLE "User" (
"id" TEXT PRIMARY KEY,
"email" TEXT UNIQUE NOT NULL,
"name" TEXT,
- "stripeCustomerId" TEXT UNIQUE
+ "stripeCustomerId" TEXT UNIQUE,
+ "macro_user_id" UUID NOT NULL,
+ FOREIGN KEY ("macro_user_id") REFERENCES "macro_user"("id")
);
CREATE TABLE "Permission" (
diff --git a/rust/cloud-storage/system_properties/fixtures/system_properties.sql b/rust/cloud-storage/system_properties/fixtures/system_properties.sql
index 6b5bc5a467..aa01c47ba4 100644
--- a/rust/cloud-storage/system_properties/fixtures/system_properties.sql
+++ b/rust/cloud-storage/system_properties/fixtures/system_properties.sql
@@ -1,8 +1,13 @@
-- Test fixture for system properties
+-- Test macro_user (same as properties_db_client fixtures)
+INSERT INTO "macro_user" (id, username, email, stripe_customer_id)
+VALUES ('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'cus_test1')
+ON CONFLICT (id) DO NOTHING;
+
-- Test user (same as properties_db_client fixtures)
-INSERT INTO "User" (id, email, name, "stripeCustomerId")
-VALUES ('user1', '[email protected]', 'Test User 1', 'cus_test1')
+INSERT INTO "User" (id, email, name, "stripeCustomerId", macro_user_id)
+VALUES ('user1', '[email protected]', 'Test User 1', 'cus_test1', 'a1111111-1111-1111-1111-111111111111')
ON CONFLICT (id) DO NOTHING;
-- Custom property definitions
diff --git a/rust/cloud-storage/target/lambda/organization_retention_handler/bootstrap.zip b/rust/cloud-storage/target/lambda/organization_retention_handler/bootstrap.zip
index 95b82ddb40..b8f4524f36 100644
Binary files a/rust/cloud-storage/target/lambda/organization_retention_handler/bootstrap.zip and b/rust/cloud-storage/target/lambda/organization_retention_handler/bootstrap.zip differ
diff --git a/rust/cloud-storage/teams/fixtures/teams.sql b/rust/cloud-storage/teams/fixtures/teams.sql
index a67dcb7b1f..76f2a9f20d 100644
--- a/rust/cloud-storage/teams/fixtures/teams.sql
+++ b/rust/cloud-storage/teams/fixtures/teams.sql
@@ -1,8 +1,15 @@
-INSERT INTO "User" ("id", "email", "name", "stripeCustomerId") VALUES
-('macro|[email protected]', '[email protected]', 'User', 'cus_1234'),
-('macro|[email protected]', '[email protected]', 'User2', NULL),
-('macro|[email protected]', '[email protected]', 'User3', NULL),
-('macro|[email protected]', '[email protected]', 'User4', NULL);
+INSERT INTO "macro_user" (id, username, email, stripe_customer_id)
+VALUES
+ ('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'cus_1234'),
+ ('a2222222-2222-2222-2222-222222222222', '[email protected]', '[email protected]', 'stripe_user2'),
+ ('a3333333-3333-3333-3333-333333333333', '[email protected]', '[email protected]', 'stripe_user3'),
+ ('a4444444-4444-4444-4444-444444444444', '[email protected]', '[email protected]', 'stripe_user4');
+
+INSERT INTO "User" ("id", "email", "name", "stripeCustomerId", "macro_user_id") VALUES
+('macro|[email protected]', '[email protected]', 'User', 'cus_1234', 'a1111111-1111-1111-1111-111111111111'),
+('macro|[email protected]', '[email protected]', 'User2', NULL, 'a2222222-2222-2222-2222-222222222222'),
+('macro|[email protected]', '[email protected]', 'User3', NULL, 'a3333333-3333-3333-3333-333333333333'),
+('macro|[email protected]', '[email protected]', 'User4', NULL, 'a4444444-4444-4444-4444-444444444444');
INSERT INTO team(id, name, owner_id, subscription_id, seat_count)
VALUES ('11111111-1111-1111-1111-111111111111', 'team1', 'macro|[email protected]', 'sub_1', 3), -- seat count is 3 for 2 invites and 1 member