Repository navigation
NOT NULL constraint failed after Laravel 11 upgrade #52182
Unanswered
joshembling
asked this question in
General
Replies: 3 comments 2 replies
|
Hi. From experience, change() usually replaces the column definition except that when the type is the same, then only the specified attributes change on mysql from what I saw. Ex length for strings and the default remains the same if not specified. In mysql your change would transform the tiny int into int so I guess that is a type change. |
2 replies
|
See this. #52180 (comment) It seems it is expected nehavior acc. to documentation. |
0 replies
|
This is expected behavior since 10.x. You may check PR #45487 that explains the reason behind this. Also explained on 11.x upgrade guide. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I have a bunch of these errors happening since upgrading to Laravel 11 and figured out it is due to some migrations where the column type has changed.
Original:
$table->boolean('enable')->default(1);Updated:
$table->integer('enable')->change();It seems to lose the default value when changing the type. This has never been an issue as far as I am aware in previous versions.
It is fixed by doing this:
$table->integer('enable')->change()->default(1);Does anyone know if this is a bug or expected behaviour? I can see both points.
All reactions