Surprisingly or not, for NOT NULL
fields ->default(null)
removes the default from a table:
public function up()
{
Schema::table('client', function (Blueprint $table) {
$table->boolean('enabled')->default(null)->change();
});
}
Just omitting the default()
part doesn’t work, since laravel
makes a diff between current state and current state + specified changes. No changes specified, no diff.
After that, doctrine
generates ALTER TABLE statement, treating NULL
as no default value.
With nullable fields though, from what I can see, doctrine
doesn’t let you simply drop the default. The only option is supposedly to make them NOT NULL
:
public function up()
{
Schema::table('client', function (Blueprint $table) {
$table->boolean('enabled')->nullable(false)->default(null)->change();
});
}
Maybe with PostgreSQL you can get away without converting to NOT NULL
, but that’s to be confirmed.