How can I create non-null columns in laravel 5.7 by migrating?
$table->string('title','50')->nullable();
does not work.
What can I do?
How can I create non-null columns in laravel 5.7 by migrating?
$table->string('title','50')->nullable();
does not work.
What can I do?
When you migrate to add a column to a table that already has records, you will need to make it nullable, or at least give it a default. Otherwise what would the value be for all of your current records?
Worst case scenario if you have no default value, make it nullable. Then go through and set the value for each one, then remove the nullable.
Your second migration (to remove nullability) would be like this:
$table->string('title','50')->nullable(false)->change();