robmorgan/phinx — pull request #313 by kryoz (2014-09-22 07:32:37+00:00)
Title: The fix to enable changing type of a column

Ran into bug with a migration.
Steps to reproduce.
First was:
public function change()
{
$table = $this->table('user_properties', ['id' => true, 'primary_key' => ['id']]);
$table->addColumn('user_id', 'integer')
->addColumn('name', 'string', ['limit' => 20])
->addColumn('sex', 'integer')
->save();

$table = $this->table('user_properties');
$table
->addColumn('city', 'string', ['limit' => 50, 'default' => null, 'null' => true])
->addColumn('birth', 'timestamp', ['default' => null, 'null' => true])
->update();
}

Then:

public function change()
{
$table = $this->table('user_properties');
$table
->changeColumn('birth', 'date', ['default' => '1930-01-01'])
->update();
}

The error:
[PDOException]
SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "NULL"
LINE 1: ...."user_properties" ALTER COLUMN "birth" TYPE DATE NULL DEFAU...