General error: 1364 Field'열 이름'doesn't have a default value 오류 처리 방법
store 방법으로 DB에 데이터를 삽입할 때
오류 "General error: 1364 Field"열 이름 "doesn"t have a default value..."
나타났어.
결론
migrate에서null열을 허용하지 않습니다.
대응
데이터를 삽입하기 전에
nullable () 를 기억하고 스크롤해서migrate를 다시 만듭니다.
단말기
$ php artisan migrate:status
$ php artisan migrate:rollback --step=1
디렉토리 파일<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddImgToDbnameTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('dbname', function (Blueprint $table) {
- $table->string("file_name")->after('content');
+ $table->string("file_name")->after('content')-->nullable();
- $table->string("file_path")->after('content');
+ $table->string("file_path")->after('content')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('dbname', function (Blueprint $table) {
$table->dropColumn("file_name");
$table->dropColumn("file_path");
});
}
}
단말기$ php artisan migrate
Reference
이 문제에 관하여(General error: 1364 Field'열 이름'doesn't have a default value 오류 처리 방법), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/makimaki_san_/items/b7b167e557b175ee84cc텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)