Open
Description
When using
protected function up(): void {
$this->changeCollation('utf8mb4_general_ci');
}
I encountered this for some tables:
[Phoenix\Exception\DatabaseQueryExecuteException (1067)]
SQLSTATE[42000]: Invalid default value for 'lang'. Query ALTER TABLE `{someTable}` CHANGE COLUMN `lang` `lang` varchar(2) CHARACTER SET
utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'NULL'; fails
The column had DEFAULT NULL
before. It only fails because the lang
field only allows 2 characters. The changeCollation()
method therefore changed many columns to DEFAULT 'NULL'
, which is obviously wrong.
I did not really find out why it's the case, but I changed the ColumnSettings::getDefault()
method to the following, which is probably wrong but works:
/**
* @return mixed
*/
public function getDefault()
{
if (isset($this->settings[self::SETTING_DEFAULT])) {
$default = $this->settings[self::SETTING_DEFAULT];
if ($default === 'NULL') {
return null;
}
return $default;
}
return null;
}
Metadata
Metadata
Assignees
Labels
No labels