如何使用字符串格式在两个表之间建立关系?我收到错误
SQLSTATE[HY000]: 常规错误: 1005 无法创建表 。(错误:150“外键约束格式不正确”)(SQL:更改表在删除级联时添加约束外键 () 引用 ())...ordercustomizesordercustomizesordercustomizes_userorder_id_foreignuserorder_iduserordersorder_number
Schema::create('ordercustomizes', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->string('userorder_id');
$table->integer('product_id')->unsigned();
$table->integer('customizetitle_id')->unsigned();
$table->integer('customizeproduct_id')->unsigned();
$table->timestamps();
$table->foreign('userorder_id')
->references('order_number')
->on('userorders')
->onDelete('cascade');
主表:
Schema::create('userorders', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->integer('product_id')->unsigned();
$table->integer('storeinfo_id')->unsigned();
$table->integer('user_id')->unsigned();
$table->string('order_number');
鸿蒙传说