Laravel migration with SQLite 'Cannot add a NOT NULL column with default value NULL'

前端 未结 8 724
隐瞒了意图╮
隐瞒了意图╮ 2020-12-05 23:50

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

8条回答
  •  执念已碎
    2020-12-05 23:58

    If you don't want the column to be nullable - then you need to let Laravel know what the default should be.

    One option is an empty string "" like this

    public function up() {
        Schema::create('users', function($table) {
          $table->date('birthday')->after('id')->default('');
          $table->string('last_name')->after('id')->default('');
          $table->string('first_name')->after('id')->default('');
    
        });
      } 
    

提交回复
热议问题