dbal
dbal copied to clipboard
RENAME TABLE instead of re-creation
This issue is related to the schema comparator. We use it to run migrations.
If I change the table name it will result into DROP TABLE
and CREATE TABLE
sql queries. This will result into a data-loss. It would be better to use the RENAME TABLE
feature.
See https://github.com/doctrine/migrations/issues/461
Which DBAL version are you using and which platform does this affect? Also some sort of information/code how to replicate this is necessary otherwise we cannot do much about it.
Doctrine\DBAL\Schema\Schema code for that are not platform-specific and about 12 years old now:
public function renameTable($oldName, $newName)
{
$table = $this->getTable($oldName);
$table->_setName($newName);
$this->dropTable($oldName);
$this->_addTable($table);
return $this;
}
See also: https://github.com/doctrine/migrations/issues/17
This method should not exist with such name, its a trap.
At the very least this method should be removed...