laravel - 外键约束的格式不正确。无法添加字符串外键
问题描述
我正在尝试创建字符串外键约束。坚果没有任何工作。帐户表-
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();
});
解决方案
推荐阅读
- python - 登录前后,我想使用相同的 URL,但使用不同的基于类的视图
- java - Java测试套接字是否是本地主机
- java - Java(IntelliJ)不会在设定的路径打开文件
- c# - 如何阅读故事板属性“From”或“To”(等)
- macos - 在 macOS 中使用 Vision 和 CoreML 对图像进行分类
- sqlite - SQLite 从连接表执行查询
- javascript - d3 SVG text element background-color with getBBox() wrong order
- r - Removing column/s from multiple data-frames
- javascript - 从 url 加载视频时出现奇怪的 Firefox 警告
- amazon-web-services - 使用 AWS Lambda Webhook 的 Dialogflow