laravel / sanctum

Laravel Sanctum provides a featherweight authentication system for SPAs and simple APIs.
https://laravel.com/docs/sanctum
MIT License
2.74k stars 294 forks source link

Vendor publish creates new migration for personal_access_tokens even with already existing table #527

Closed Sushma-Mercantile closed 1 month ago

Sushma-Mercantile commented 1 month ago

Sanctum Version

4.0.2

Laravel Version

11

PHP Version

8.2.12

Database Driver & Version

No response

Description

In a Laravel project that uses Sanctum, when I run php artisan vendor:publish, it keeps creating fresh migration files for the personal access token table. This results in multiple migration files for the same table that leads to conflict while running migration.

image

Also, I found the previous methods to ignoreMigrations is also removed and used publishesMigrations instead. ignoreMigrations would have prevented repeated creation of migration.

Steps To Reproduce

  1. Require laravel/sanctum
  2. Run php artisan vendor:publish multiple times
  3. This also runs sanctum-migrations and it copies migration to project\database\migrations
  4. Even when there is migration copied already, it stills copies the migration resulting in multiple migration for same table.
wfern commented 1 month ago

It's because of the migration configuration in the database config file: database.migrations.update_date_on_publish

    'migrations' => [
        'table' => 'migrations',
        'update_date_on_publish' => true,
    ],

Maybe it should be false by default.

Sushma-Mercantile commented 1 month ago

Thank you. This solved the issue for me, it was true by default!