Skip to content

Commit ce9bf1c

Browse files
committed
use full table name in Migrator
1 parent 7c231c9 commit ce9bf1c

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/Schema/Migrator.php

+15-4
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,24 @@ protected function createSchemaManager(): AbstractSchemaManager
8282

8383
public function table(string $tableName): self
8484
{
85-
$tableName = preg_replace('~^.+\.~', '', $tableName);
86-
87-
$this->table = new Table($this->getDatabasePlatform()->quoteIdentifier($tableName));
85+
$table = new Table('0.0');
8886
if ($this->getDatabasePlatform() instanceof MySQLPlatform) {
89-
$this->table->addOption('charset', 'utf8mb4');
87+
$table->addOption('charset', 'utf8mb4');
88+
}
89+
90+
// fix namespaced table name split for MSSQL/PostgreSQL
91+
// https://github.com/doctrine/dbal/blob/3.3.7/src/Schema/AbstractAsset.php#L55
92+
$lastDotPos = strrpos($tableName, '.');
93+
if ($lastDotPos !== false) {
94+
\Closure::bind(function () use ($table, $tableName, $lastDotPos) {
95+
$table->_quoted = true;
96+
$table->_namespace = substr($tableName, 0, $lastDotPos);
97+
$table->_name = substr($tableName, $lastDotPos + 1);
98+
}, null, Table::class)();
9099
}
91100

101+
$this->table = $table;
102+
92103
return $this;
93104
}
94105

0 commit comments

Comments
 (0)