Search code examples
laravellaravel-migrations

Laravel: migrations change default value(boolean) of column


This is my current code.

public function up()
{
    Schema::table('render', function (Blueprint $table) {
        $table->boolean('displayed')->default(1);
    });
}`

How to change the default value to 0 as below?

public function up()
{
    Schema::table('render', function (Blueprint $table) {
        $table->boolean('displayed')->default(0);
    });
}

Solution

  • public function up()
    {
        Schema::table('render', function (Blueprint $table) {
            $table->boolean('displayed')->default(0)->change();
        });
    }
    

    Added ->change(). Please see Link