Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mleontenko's avatar

Migrations - Adding columns with FALSE as default value

I'm using a migration that adds "verified" column to users table:

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddVerifiedColumn extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('users', function (Blueprint $table) {            
            $table->boolean('verified')->deafult(false);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->dropColumn('verified');
        });
    }
}

The goal is to add "verified" column and set it to false for all current users and future registered users.

When I try to run php artisan migrate, I get the following error:

SQLSTATE[23502]: Not null violation: 7 ERROR:  column "verified" contains null values (SQL: alter table "users" add column "verified" boolean not null)

Why does it contain null values? It should contain boolean value: false.

EDIT: database is postgreSQL

0 likes
1 reply
piljac1's avatar
piljac1
Best Answer
Level 28

You wrote

deafult(false);

Instead of

default(false);
2 likes

Please or to participate in this conversation.