Skip to content

Commit

Permalink
use full table name in Migrator
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Jul 11, 2022
1 parent 7c231c9 commit ce9bf1c
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/Schema/Migrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,24 @@ protected function createSchemaManager(): AbstractSchemaManager

public function table(string $tableName): self
{
$tableName = preg_replace('~^.+\.~', '', $tableName);

$this->table = new Table($this->getDatabasePlatform()->quoteIdentifier($tableName));
$table = new Table('0.0');
if ($this->getDatabasePlatform() instanceof MySQLPlatform) {
$this->table->addOption('charset', 'utf8mb4');
$table->addOption('charset', 'utf8mb4');
}

// fix namespaced table name split for MSSQL/PostgreSQL
// https://github.com/doctrine/dbal/blob/3.3.7/src/Schema/AbstractAsset.php#L55
$lastDotPos = strrpos($tableName, '.');
if ($lastDotPos !== false) {
\Closure::bind(function () use ($table, $tableName, $lastDotPos) {
$table->_quoted = true;
$table->_namespace = substr($tableName, 0, $lastDotPos);
$table->_name = substr($tableName, $lastDotPos + 1);
}, null, Table::class)();
}

$this->table = $table;

return $this;
}

Expand Down

0 comments on commit ce9bf1c

Please sign in to comment.