Documentation

MultiTenantVisitor
in package
implements Visitor

Converts a single tenant schema into a multi-tenant schema for SQL Azure Federations under the following assumptions:

  • Every table is part of the multi-tenant application, only explicitly excluded tables are non-federated. The behavior of the tables being in global or federated database is undefined. It depends on you selecting a federation before DDL statements or not.
  • Every Primary key of a federated table is extended by another column 'tenant_id' with a default value of the SQLAzure function federation_filtering_value('tenant_id').
  • You always have to work with filtering=On when using federations with this multi-tenant approach.
  • Primary keys are either using globally unique ids (GUID, Table Generator) or you explicitly add the tenent_id in every UPDATE or DELETE statement (otherwise they will affect the same-id rows from other tenents as well). SQLAzure throws errors when you try to create IDENTIY columns on federated tables.
Tags
author

Benjamin Eberlei kontakt@beberlei.de

Interfaces, Classes and Traits

Visitor
Schema Visitor used for Validation or Generation purposes.

Table of Contents

$distributionName  : string
Name of the federation distribution, defaulting to the tenantColumnName if not specified.
$excludedTables  : array<string|int, mixed>
$tenantColumnName  : string
$tenantColumnType  : string
__construct()  : mixed
acceptColumn()  : void
acceptForeignKey()  : void
acceptIndex()  : void
acceptSchema()  : void
acceptSequence()  : void
acceptTable()  : void
getClusteredIndex()  : Index

Properties

$distributionName

Name of the federation distribution, defaulting to the tenantColumnName if not specified.

private string $distributionName

Methods

__construct()

public __construct([array<string|int, mixed> $excludedTables = array() ][, string $tenantColumnName = 'tenant_id' ][, string|null $distributionName = null ]) : mixed
Parameters
$excludedTables : array<string|int, mixed> = array()
$tenantColumnName : string = 'tenant_id'
$distributionName : string|null = null
Return values
mixed

Search results