class MultiTenantVisitor implements Visitor (View source)

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.

Methods

__construct(array $excludedTables = array(), string $tenantColumnName = 'tenant_id', string|null $distributionName = null)

No description

void
acceptTable(Table $table)

No description

void
acceptSchema(Schema $schema)

No description

void
acceptColumn(Table $table, Column $column)

No description

void
acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint)

No description

void
acceptIndex(Table $table, Index $index)

No description

void
acceptSequence(Sequence $sequence)

No description

Details

__construct(array $excludedTables = array(), string $tenantColumnName = 'tenant_id', string|null $distributionName = null)

Parameters

array $excludedTables
string $tenantColumnName
string|null $distributionName

void acceptTable(Table $table)

Parameters

Table $table

Return Value

void

void acceptSchema(Schema $schema)

Parameters

Schema $schema

Return Value

void

void acceptColumn(Table $table, Column $column)

Parameters

Table $table
Column $column

Return Value

void

void acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint)

Parameters

Table $localTable
ForeignKeyConstraint $fkConstraint

Return Value

void

void acceptIndex(Table $table, Index $index)

Parameters

Table $table
Index $index

Return Value

void

void acceptSequence(Sequence $sequence)

Parameters

Sequence $sequence

Return Value

void