我正在尝试创建字符串外键约束。坚果什么都没有用。帐户表-
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();
});
我认为两个表中的引擎应该相同:
$table->engine = 'InnoDB';
另外请尝试在两个表中为字符串$table->string('customer_id',40)
定义一个特定的长度。