【问题标题】:ERROR 1005: Can't create table (errno: 150)错误 1005:无法创建表(错误号:150)
【发布时间】:2020-04-01 14:05:36
【问题描述】:

我该如何解决这个问题我已经尝试了所有可能的解决方案,但什么也没发生。只是显示相同的错误

错误 1005:无法创建表(错误号:150)

这是代码:

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

class CreateAttributeValueProductAttributeTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
    */
    public function up()
    {
        Schema::create('attribute_value_product_attribute', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->bigInteger('attribute_value_id')->unsigned();
            $table->foreign('attribute_value_id')->references('id')->on('attribute_values');
            $table->bigInteger('product_attribute_id')->unsigned();
            $table->foreign('product_attribute_id')->references('id')->on('product_attributes');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('attribute_value_product_attribute');
    }
}

【问题讨论】:

  • 能否请您发布完整的错误

标签: mysql laravel


【解决方案1】:
    $table->increments('id');
        $table->integer('attribute_value_id')->unsigned();
        $table->foreign('attribute_value_id')->references('id')->on('attribute_values');
        $table->integer('product_attribute_id')->unsigned();
        $table->foreign('product_attribute_id')->references('id')->on('product_attributes');$table->timestamps();

请按原样复制粘贴,让我知道它是否适合您,如果不是,请告诉我确切的错误。谢谢

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-11-29
    • 1970-01-01
    • 2012-02-19
    • 2020-04-10
    • 2013-07-22
    • 2013-08-17
    • 2013-02-07
    • 2017-04-09
    相关资源
    最近更新 更多