Why am I getting this warning when using the SQLite driver? I have no problems with the MySQL driver but SQLite is throwing this error.
It does not make sense to me
Another work around for this issue is to first create the fields as nullable and then later change the fields to be not null. So for example in this case we will do something like the following:
public function up() {
// Create fields first as nullable
Schema::table('users', function(Blueprint $table) {
$table->date('birthday')->after('id')->nullable();
$table->string('last_name')->after('id')->nullable();
$table->string('first_name')->after('id')->nullable();
});
// Either truncate existing records or assign a value to new fields
if (true) {
DB::table('users')->truncate();
} else {
DB::table('users')->update([
'birthday' => '2019-05-01',
'last_name' => 'last name',
'first_name' => 'first name',
]);
}
// Change the fields to not be null
Schema::table('users', function(Blueprint $table) {
$table->date('birthday')->nullable(false)->change();
$table->string('last_name')->nullable(false)->change();
$table->string('first_name')->nullable(false)->change();
});
}