6 declare(strict_types=1);
24 private $replicaTableSuffix =
'_replica';
32 private $outdatedTableSuffix =
'_outdated';
37 private $resourceConnection;
42 private $indexNameResolver;
53 $this->indexNameResolver = $indexNameResolver;
59 public function switch(
IndexName $indexName,
string $connectionName):
void 61 $connection = $this->resourceConnection->getConnection($connectionName);
62 $tableName = $this->indexNameResolver->resolveName($indexName);
78 $outdatedTableName =
$tableName . $this->outdatedTableSuffix;
79 $replicaTableName =
$tableName . $this->replicaTableSuffix;
84 'newName' => $outdatedTableName,
87 'oldName' => $replicaTableName,
91 'oldName' => $outdatedTableName,
92 'newName' => $replicaTableName,
95 $toRename = array_merge($toRename, $renameBatch);
98 if (!empty($toRename)) {
__construct(ResourceConnection $resourceConnection, IndexNameResolverInterface $indexNameResolver)