Doctrine\DBAL\Sharding\SQLAzure\Schema\MultiTenantVisitor
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.
- Author: Benjamin Eberlei <kontakt@beberlei.de>
Synopsis
- // members
- private array $excludedTables;
- private string $tenantColumnName;
- private string $tenantColumnType;
- private string $distributionName;
- // methods
- public void __construct()
- public void acceptTable()
- private void getClusteredIndex()
- public void acceptSchema()
- public void acceptColumn()
- public void acceptForeignKey()
- public void acceptIndex()
- public void acceptSequence()
Hierarchy
Implements
Members
private
- $distributionName
—
string
Name of the federation distribution, defaulting to the tenantColumnName if not specified. - $excludedTables — array
- $tenantColumnName — string
- $tenantColumnType — string