Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel migration using migrations that dont exist

I am trying do to a very basic migration. When i run php artisan migrate i get this error:

Migrating: 2019_12_14_000001_create_personal_access_tokens_table
 Illuminate\Database\QueryException 
  SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'personal_access_tokens' already exists (SQL: create tab....///

As you can see, I dont have that "2019_12_14_000001_create_personal_access_tokens_table" migration in my migrations table.

enter image description here

I have done the following:

php artisan cache:clear
php artisan config:clear
./composer dump-autoload

And im still getting this ghost migration. What should i do?

The contents of the create_file_table file I am trying to run is:

 public function up()
{
    Schema::create('files', function (Blueprint $table) {
        $table->id();
        $table->string('quoteNumber');
        $table->string('purchaseOrderNumber');
        $table->string('name')->nullable();
        $table->string('file_path')->nullable();
        $table->timestamps();
    });
}
like image 257
bart2puck Avatar asked Dec 17 '25 13:12

bart2puck


1 Answers

2019_12_14_000001_create_personal_access_tokens_table

Is part of Laravel Sanctum.

You can publish it to your migrations folder by running the following command.

php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider"

Otherwise it stays with the package and you will not see it in your migrations folder.

If you would like to ignore it you can follow the documentation included below.

Migration Customization

If you are not going to use Sanctum's default migrations, you should call the Sanctum::ignoreMigrations method in the register method of your App\Providers\AppServiceProvider class. You may export the default migrations by executing the following command:

php artisan vendor:publish --tag=sanctum-migrations

like image 188
whoacowboy Avatar answered Dec 19 '25 05:12

whoacowboy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!