4

Am using Laravel 5.6

I Tried to migrate purchases table for my project
When i tried to migrate and it's showing Table Space error.

General error: 1813 Tablespace for table 'jshop.purchases' exists. Please DISCARD the tablespace before IMPORT.

Migrate Code Below :

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');
    });

invoice,products,weights table are valid in my database.

Error Message Image Below : Migration Error image Link How to solve this ?

Full Migration Code Image

Ripon Uddin
  • 709
  • 3
  • 14
  • 29
  • can you share full migrate code? – sanduniYW Oct 02 '18 at 06:23
  • Refer this question https://stackoverflow.com/questions/15694168/error-tablespace-for-table-xxx-exists-please-discard-the-tablespace-before-imp – Gihan Lakshan Oct 02 '18 at 06:24
  • @sanduniYW sir when am trying to put all code its warning me about length of code. That's why i shared image link below https://i.stack.imgur.com/yeH83.jpg please open this. – Ripon Uddin Oct 02 '18 at 06:31
  • kk..thanks. I add answer below. Plz try it. – sanduniYW Oct 02 '18 at 06:40
  • please put the relevant code in the question as text and not an image. this question becomes less useful if the image link goes down... – bunbun Oct 02 '18 at 06:40
  • @bunbun sir at first i added every single code of this migration. But stack authority showing some error that's y i have to re-edit this code – Ripon Uddin Oct 02 '18 at 06:58

4 Answers4

8

try this:

php artisan migrate:refresh

if it is not solve this error try this:

Go to mysql/data/database_name /tablename.ibd file and delete it manually. after this try your command php artisan migrate

sanduniYW
  • 723
  • 11
  • 19
8

Drop the database and create a new one.

1

Your database is corrupted, do the followinf steps to fix it.

SETP 1. Drop the database and create a new one.

SETP 1. run the following command

php artisan migrate:refresh
MUHINDO
  • 788
  • 6
  • 10
0

Locate where your database is and delete the table. Then run PHP artisan migrate This worked for me