Skip to content

Multi-Tenancy through "TenantId" column in document tables #750

Description

@jeremydmiller

Splitting off from #435. A tenancy strategy where all tenants are stored in the same tables, but we use some kind of "tenant id" column to segregate data. You could always just do this yourself as long as you remember to always query by the right tenant id, but it'd be a lot easier if Marten just supported this pattern.

I think this one is straight forward enough that it'll be the first strategy and create the template for acceptance tests.

General Tasks:

  • New tenancy strategy (see Support for multi tenancy at documentStore level #435) for this approach
  • New TenantIdColumn that gets added to the document table when the flag is set
  • Addition to the upsert function logic
  • Verify that you cannot update a document that isn't part of your tenant
  • Need to apply tenant id in upserts
  • Add tenant id to the DocumentMetadata
  • Compiled Queries will have to have some kind of special logic
  • FindJson methods (!)
  • Patching API respects tenancy -- should just be a test at this point
  • Add an index to the tenant id field // cc @mdissel
  • Test bulk inserts -- should already be working, but still needs a test
  • Batch queries

Default where fragment logic on DocumentMapping when it's multi-tenanted

  • Not soft deleted, not hierarchical
  • Soft deleted, not hierarchical
  • Not soft deleted, base type of hierarchy
  • Not soft deleted, leaf type in hierarchy

Filter() logic on DocumentMapping when it's multi-tenanted

  • Not soft deleted, not hierarchical
  • Soft deleted, not hierarchical
  • Not soft deleted, base type of hierarchy
  • Not soft deleted, leaf type in hierarchy

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions