首页 > 解决方案 > 外键约束的格式不正确。无法添加字符串外键

问题描述

我正在尝试创建字符串外键约束。坚果没有任何工作。帐户表-

Schema::create('accounts', function (Blueprint $table) {
        $table->engine = 'InnoDB';
        $table->string('customer_id');
        $table->foreign('customer_id')->references('customer_id')->on('customers');
        $table->string('ac_type_id');
        $table->string('ac_number')->primary();
        $table->string('ac_balance');
        $table->string('password');
        $table->timestamps();
    });

客户表-

Schema::create('customers', function (Blueprint $table) {
        $table->string('customer_id')->primary();
        $table->string('first_name');
        $table->string('last_name');
        $table->string('mobile_no');
        $table->string('email_id');
        $table->string('address');
        $table->date('dob');[enter image description here][1]
        $table->timestamps();
    });

这是我经常遇到的错误 这是我经常遇到的错误

标签: laraveldatabase-migration

解决方案


推荐阅读