Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mahsanr44's avatar

Illuminate\Database\QueryException

I'm trying to migrate a table in database and this table isn't exists there but getting this error:

SQLSTATE[HY000]: General error: 1813 Tablespace for table '`betterhorizon`.`subscriptions`' exists. Please DISCARD the tablespace before IMPORT (SQL: create table `subscriptions` (`id` bigint unsigned not null auto_increment primary key, `month` int not null, `price` double(8, 2) not null, `status` tinyint not null default '1', `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')
0 likes
9 replies
saedyousef's avatar

@yaelahrep Please share your migration file, there is many things could cause this error. Let's make sure it's not in the migration

mahsanr44's avatar

@saedyousef

<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('subscriptions', function (Blueprint $table) {
            $table->id();
            $table->integer('month');
            $table->float('price');
            $table->tinyInteger('status')->default(1);
            $table->timestamps();
        });
    }

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

Sinnbeck's avatar

@mahsanr44 And you have no table named "subscriptions" if you open your database editor? Be sure to not just assume. Actually check it

Sinnbeck's avatar

This sounds like an environment specific error. Like a left over file from earlier or similar. What are you running this on ? Xampp?

Please or to participate in this conversation.