Illuminate\Database\QueryException:SQLSTATE[HY000]:一般错误:1813 表的表空间

Rip*_*din 4 php mysql laravel laravel-5.6

我使用 Laravel 5.6

我尝试迁移项目的购买表
当我尝试迁移时,它显示表空间错误。

一般错误:1813 表 ' 的表空间jshoppurchases' 存在。请在导入之前丢弃表空间。

迁移代码如下:

Schema::create('purchases', function (Blueprint $table) {
        $table->increments('id');
        $table->integer("product_price");
        $table->integer("product_qty");
        $table->unsignedInteger('invoice_id');
        $table->unsignedInteger('product_id');
        $table->unsignedInteger('weight_id');
        $table->timestamps();
        $table->foreign("invoice_id")->references('id')->on('invoices');
        $table->foreign("product_id")->references('id')->on('products');
        $table->foreign("weight_id")->references('id')->on('weights');
    });
Run Code Online (Sandbox Code Playgroud)

发票、产品、重量表在我的数据库中有效。

错误消息图片如下: 迁移错误图片链接 如何解决此问题?

完整迁移代码图像

小智 9

删除数据库并创建一个新数据库。


san*_*iYW 8

尝试这个:

php artisan migrate:refresh
Run Code Online (Sandbox Code Playgroud)

如果不能解决此错误,请尝试以下操作:

转到mysql/data/database_name /tablename.ibd file并手动删除它。之后尝试你的命令php artisan migrate