Laravel: migrations change default value(boolean) of column

Tomeikun picture Tomeikun · Apr 24, 2018 · Viewed 31.8k times · Source

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);
    });
}

Answer

Ganesh Ghalame picture Ganesh Ghalame · Apr 24, 2018
public function up()
{
    Schema::table('render', function (Blueprint $table) {
        $table->boolean('displayed')->default(0)->change();
    });
}

Added ->change(). Please see Link