我有一个已经分配了默认值的表.举个例子,我们可以看看以下内容:
Schema::create('users', function (Blueprint $table) {
$table->increments('id')->unsigned();
$table->integer('active')->default(1);
});
Run Code Online (Sandbox Code Playgroud)
我现在想要在活动字段上更改我的默认值.我期待做这样的事情:
if (Schema::hasTable('users')) {
Schema::table('users', function (Blueprint $table) {
if (Schema::hasColumn('users', 'active')) {
$table->integer('active')->default(0);
}
});
}
Run Code Online (Sandbox Code Playgroud)
但当然它告诉我专栏已经存在.如何在不删除列的情况下简单地更新列x的默认值?