SQLSTATE [42000]:语法错误或访问冲突:1067'fechaNacimiento'的默认值无效-laravel

问题描述 投票:0回答:1

执行迁移时发生错误

enter image description here

移民:

<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class MakeSomeColumnsNullableToPacientesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('pacientes', function (Blueprint $table) {
            $table->integer('obra_social_id')->unsigned()->nullable()->change();
            $table->integer('plan_id')->unsigned()->nullable()->change();

            $table->integer('pais_id')->unsigned()->nullable()->change();
            $table->integer('provincia_id')->unsigned()->nullable()->change();
            $table->integer('localidad_id')->unsigned()->nullable()->change();

            $table->date('fechaNacimiento')->nullable()->change();
            $table->string('telefono', 25)->nullable()->change();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('pacientes', function (Blueprint $table) {
            $table->integer('obra_social_id')->unsigned()->change();
            $table->integer('plan_id')->unsigned()->change();
        });
    }
}




帮助请由于此错误,它使我无法很好地执行迁移

fechaNacimiento == 出生日期

原始表格:$ table-> date('fechaNacimiento');

php mysql laravel
1个回答
0
投票

尝试为您的列设置默认值:

$table->date('fechaNacimiento')->nullable()->default(NULL)->change();

或:

 $table->date('fechaNacimiento')->nullable()->default('DEFAULT')->change();
© www.soinside.com 2019 - 2024. All rights reserved.