Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Phinx/Db/Adapter/MysqlAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ protected function getRenameColumnInstructions(string $tableName, string $column

return true;
});
$extra = implode(' ', $extras);
$extra = ' ' . implode(' ', $extras);

if (($row['Default'] !== null)) {
$extra .= $this->getDefaultValueDefinition($row['Default']);
Expand Down
13 changes: 13 additions & 0 deletions tests/Phinx/Db/Adapter/MysqlAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,19 @@ public function testRenameColumn()
$this->assertTrue($this->adapter->hasColumn('t', 'column2'));
}

public function testRenameNonNullColumnWithExtra()
{
// Extra = "AUTO_INCREMENT" for the id column
$table = new Table('t', [], $this->adapter);
$table->save();
$this->assertTrue($this->adapter->hasColumn('t', 'id'));
$this->assertFalse($this->adapter->hasColumn('t', 'new_id'));

$table->renameColumn('id', 'new_id')->save();
$this->assertFalse($this->adapter->hasColumn('t', 'id'));
$this->assertTrue($this->adapter->hasColumn('t', 'new_id'));
}

public function testRenameColumnPreserveComment()
{
$table = new Table('t', [], $this->adapter);
Expand Down