Php Laravel:SQLSTATE[HY000]:一般错误:1005 Can';不创建表

Php Laravel:SQLSTATE[HY000]:一般错误:1005 Can';不创建表,php,mysql,laravel,migration,migrate,Php,Mysql,Laravel,Migration,Migrate,我有一个数据透视表,当文章被删除时,数据透视表也会被更新 在php artisan migrate:fresh上显示此错误 SQLSTATE[HY000]:一般错误:1005无法创建表testcategory\u post\u pad(错误号:150“外键约束格式不正确”)(SQL:alter tablecategory\u post\u pad添加约束category\u post\u pad\u post id\u Foreign外键(post\id)引用posts(id)在删除级联上) 迁

我有一个数据透视表,当文章被删除时,数据透视表也会被更新 在php artisan migrate:fresh上显示此错误

SQLSTATE[HY000]:一般错误:1005无法创建表
test
category\u post\u pad
(错误号:150“外键约束格式不正确”)(SQL:alter table
category\u post\u pad
添加约束
category\u post\u pad\u post id\u Foreign
外键(
post\id
)引用
posts
id
)在删除级联上)

迁移:

public function up()
{
    Schema::create('category_post_pad', function (Blueprint $table) {
        $table->unsignedInteger('category_id');
        $table->unsignedInteger('post_id');
        $table->foreign('post_id')
            ->references('id')
            ->on('posts')
            ->onDelete('cascade');
        $table->unsignedInteger('pad_id');

    });
}

posts
id
是迁移中的整数还是bigInteger?如果是bigInteger,则其类型与外键类型之间会有冲突。请修改posts的主键,或更改外键的
unsignedBigInteger
,您将在post-ta中使用不同的id数据类型ble和post_id的数据类型为usignedInteger