I am trying to give 'is_img' column to default value '0' during migration. When I am trying like - $table->integer('is_img')->defalut(0)->change();
It's removing existing column during migration. When trying without change() method, then it's giving null value during migration. What should I do to keep the default value for the column during migration? Here is Schema bellow -
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();
});
}
You have a typo in this line:
$table->integer('is_img')->defalut(0)->change();
Should be default(0)
not defalut(0)
.
It was typo mistake to 'defalut', should be 'default', $table->integer('is_img')->default(0);
is working fine. Thanks @Esteban Garcia and @Hiren Gohel for saving my time.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.