Skip to content

Support conjoined tenancy for DCB tags and natural keys#4206

Merged
jeremydmiller merged 1 commit intomasterfrom
claude/affectionate-liskov
Mar 25, 2026
Merged

Support conjoined tenancy for DCB tags and natural keys#4206
jeremydmiller merged 1 commit intomasterfrom
claude/affectionate-liskov

Conversation

@jeremydmiller
Copy link
Copy Markdown
Member

Summary

  • Add tenant_id column to EventTagTable and NaturalKeyTable primary keys when using conjoined tenancy
  • Fix NaturalKeyTable foreign keys to mt_streams to include tenant_id (and is_archived when partitioned), resolving the FK mismatch described in Generated DB patch scripts for natural key tables do not account for conjoined multitenancy #4201
  • Add tenant_id filtering to all DCB tag queries (QueryByTags, EventsExist, AssertDcbConsistency, FetchForWritingByTags) for proper tenant isolation
  • Update tag insert operations (InsertEventTagOperation, InsertEventTagByEventIdOperation, AssignTagWhereOperation, QuickAppendEventFunction) to include tenant_id
  • Update NaturalKeyProjection upsert ON CONFLICT clause to include tenant_id

Closes #4201

Test plan

  • 9 new conjoined tenancy DCB tag tests (tag query isolation, events exist isolation, aggregate isolation, fetch-for-writing isolation, cross-tenant no conflict, same-tenant conflict detection, schema creation with archived partitioning)
  • 8 new conjoined tenancy natural key tests (same key in different tenants, fetch-for-writing isolation, fetch-latest isolation, schema creation with archived partitioning)
  • All 24 existing DCB tag tests pass
  • All 15 existing natural key tests pass
  • All 4 Bug_4190 archived partitioning tests pass
  • All 15 quick-append and assign-tag-where tests pass

🤖 Generated with Claude Code

Add tenant_id column to EventTagTable and NaturalKeyTable primary keys
when using conjoined tenancy. Fix NaturalKeyTable foreign keys to
mt_streams to include tenant_id (and is_archived when partitioned).
Add tenant_id filtering to all DCB tag queries (QueryByTags,
EventsExist, AssertDcbConsistency, FetchForWritingByTags) and tag
insert operations. Update NaturalKeyProjection upsert ON CONFLICT
clause and QuickAppendEventFunction tag inserts for tenant isolation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generated DB patch scripts for natural key tables do not account for conjoined multitenancy

1 participant