gpt4 book ai didi

php - 在迁移期间使列默认值在 laravel 5.5 中不起作用

转载 作者:行者123 更新时间:2023-11-29 01:19:42 25 4
gpt4 key购买 nike

我试图在迁移过程中将“is_img”列设置为默认值“0”。当我尝试像 - $table->integer('is_img')->defalut(0)->change(); 它在迁移期间删除现有列。当尝试不使用 change() 方法时,它会在迁移过程中给出 null 值。我应该怎么做才能在迁移过程中保留列的默认值?这是下面的架构 -

public function up()
{
Schema::create('admins', function (Blueprint $table) {
$table->increments('id');
$table->string('email');
$table->string('user_name');
$table->string('password');
$table->string('login_type');
$table->integer('is_img')->defalut(0)->change();
$table->timestamps();
});
}

最佳答案

你在这一行中有错字:

$table->integer('is_img')->defalut(0)->change();

应该是 default(0) 而不是 defalut(0)

关于php - 在迁移期间使列默认值在 laravel 5.5 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48319730/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com