You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While trying to rename nullable numeric column, migration fails. It tries to gather data from existing schema as seen in Illuminate\Database\Schema\Grammars@343 (function compileLegacyRenameColumn). On line 357 it checks if it has default timestamp, which in our case had not. So $column['default'] was used as is. But schema returned default value as 'NULL'. Since it is string it tried to set default value as 'NULL' for numeric column thus crashing.
Laravel Version
11
PHP Version
8.3
Database Driver & Version
Maria before 10.5.2 (10.3.39 in our case)
Description
While trying to rename nullable numeric column, migration fails. It tries to gather data from existing schema as seen in Illuminate\Database\Schema\Grammars@343 (function compileLegacyRenameColumn). On line 357 it checks if it has default timestamp, which in our case had not. So $column['default'] was used as is. But schema returned default value as 'NULL'. Since it is string it tried to set default value as 'NULL' for numeric column thus crashing.
Our solution was to patch
'default' => $column['default'] && str_starts_with(strtolower($column['default']), 'current_timestamp')
to
'default' => (($column['default'] && str_starts_with(strtolower($column['default']), 'current_timestamp')) || ($column['default'] === 'NULL'))
Afterwards migration succeeded.
I honestly don't know if the problem lies in schema or in unpatched check. So this is as much as i can do.
Steps To Reproduce
Rename numeric nullable column in maria before version 10.5.2
The text was updated successfully, but these errors were encountered: