Skip to content

Ability to re-use an existing database table for the MasterTableTenancy strategy #3136

@cdunnkiplot

Description

@cdunnkiplot

Hi, I have a multi-tenant service that is already using an existing tenant master table that contains the tenant identifier and connection string. I added Marten v7.5 and tried to configure the master table tenant strategy but I found the MasterTableTenancyOptions would not let me configure it to use my existing database table. Currently, it only allows you to configure the SchemaName.

Here is my existing master table schema definition:

CREATE TABLE integration.tenant_config
(
    name text COLLATE pg_catalog."default" NOT NULL,
    connection_string text COLLATE pg_catalog."default" NOT NULL,
    CONSTRAINT "PK_tenant_config" PRIMARY KEY (name)
)

As a result, I've had to copy your MasterTableTenancy class into my solution and refactor it so that the datatable table name and columns match the existing master table I already have. My implementation is naive as I've just the hard coded table and column names but so far this works well for me.

I am raising this issue to please ask whether the MasterTableTenancy and MasterTableTenancyOptions can be enhanced to allow users to further configure the database schema for this master table. As well as the db schema, it'd be useful to allow users to configure the table name and column names.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions