[documentation] Cannot declare class CreateTwoFactorAuthenticationsTable, because the name is already in use
Closed this issue · 7 comments
Documentation says you can change the migration file by running this command.
php artisan vendor:publish --provider="DarkGhostHunter\Laraguard\LaraguardServiceProvider" --tag="migrations"
But then you cannot run 'php artisan migrate' anymore.
php artisan migrate
Symfony\Component\ErrorHandler\Error\FatalError
Cannot declare class CreateTwoFactorAuthenticationsTable, because the name is already in use
at \database\migrations\2020_07_16_162410_create_two_factor_authentications_table.php:42
38| public function down()
39| {
40| Schema::dropIfExists('two_factor_authentications');
41| }
> 42| }
43|
Whoops\Exception\ErrorException
Cannot declare class CreateTwoFactorAuthenticationsTable, because the name is already in use
at \database\migrations\2020_07_16_162410_create_two_factor_authentications_table.php:42
38| public function down()
39| {
40| Schema::dropIfExists('two_factor_authentications');
41| }
> 42| }
43|
1 \vendor\filp\whoops\src\Whoops\Run.php:408
Whoops\Run::handleError("Cannot declare class CreateTwoFactorAuthenticationsTable, because the name is already in use", "\database\migrations\2020_07_16_162410_create_two_factor_authentications_table.php")
2 [internal]:0
Whoops\Run::handleShutdown()
Delete the created file and then you can run migrate.
Of course, Laravel migrations...
I'll patch it. This happens because the package loads the migrations forcefully, always. If you copy one, the class the duplicated.
Now, migrations aren't loaded outside console commands AFAIK, so you will get that error on CLI.
I have to make the migration programmatically load only if the class doesn't exists. Publishing the migration file should be the same, because if you publish everything you won't notice you got a duplicated migration file.
I think I should push an issue to the framework.
Pushed a patch on dev-master
, it should work now. Waiting confirmation.
Did a quick test for you on clean project and error is fixed.
> php artisan vendor:publish --provider="DarkGhostHunter\Laraguard\LaraguardServiceProvider" --tag="migrations"
Copied File [\vendor\darkghosthunter\laraguard\database\migrations\2020_04_02_000000_create_two_factor_authentications_table.php] To
[\database\migrations\2020_07_17_112006_create_two_factor_authentications_table.php]
Publishing complete.
> php artisan migrate
Migrating: 2020_07_17_112006_create_two_factor_authentications_table
Migrated: 2020_07_17_112006_create_two_factor_authentications_table (0.05 seconds)
Thanks, I'll push it to stable.
Hi im downloaded composer require darkghosthunter/laraguard
after that from documentation use
/app # php artisan vendor:publish --provider="DarkGhostHunter\Laraguard\LaraguardServiceProvider" --tag="migrations" Copied File [/vendor/darkghosthunter/laraguard/database/migrations/2020_04_02_000000_create_two_factor_authentications_table.php] To [/database/migrations/2020_08_31_155340_create_two_factor_authentications_table.php] Publishing complete.
but on the next step i have the same problem
` php artisan migrate
[31-Aug-2020 15:53:44 UTC] PHP Fatal error: Cannot declare class CreateTwoFactorAuthenticationsTable, because the name is already in use in /app/database/migrations/2020_08_31_155340_create_two_factor_authentications_table.php on line 0
[31-Aug-2020 15:53:44 UTC] PHP Stack trace:
[31-Aug-2020 15:53:44 UTC] PHP 1. {main}() /app/artisan:0
[31-Aug-2020 15:53:44 UTC] PHP 2. App\Console\Kernel->handle() /app/artisan:37
[31-Aug-2020 15:53:44 UTC] PHP 3. Illuminate\Console\Application->run() /app/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:129
[31-Aug-2020 15:53:44 UTC] PHP 4. Illuminate\Console\Application->run() /app/vendor/laravel/framework/src/Illuminate/Console/Application.php:93
[31-Aug-2020 15:53:44 UTC] PHP 5. Illuminate\Console\Application->doRun() /app/vendor/symfony/console/Application.php:140
[31-Aug-2020 15:53:44 UTC] PHP 6. Illuminate\Console\Application->doRunCommand() /app/vendor/symfony/console/Application.php:264
[31-Aug-2020 15:53:44 UTC] PHP 7. Illuminate\Database\Console\Migrations\MigrateCommand->run() /app/vendor/symfony/console/Application.php:911
[31-Aug-2020 15:53:44 UTC] PHP 8. Illuminate\Database\Console\Migrations\MigrateCommand->run() /app/vendor/laravel/framework/src/Illuminate/Console/Command.php:121
[31-Aug-2020 15:53:44 UTC] PHP 9. Illuminate\Database\Console\Migrations\MigrateCommand->execute() /app/vendor/symfony/console/Command/Command.php:258
[31-Aug-2020 15:53:44 UTC] PHP 10. Illuminate\Foundation\Application->call() /app/vendor/laravel/framework/src/Illuminate/Console/Command.php:134
[31-Aug-2020 15:53:44 UTC] PHP 11. Illuminate\Container\BoundMethod::call() /app/vendor/laravel/framework/src/Illuminate/Container/Container.php:596
[31-Aug-2020 15:53:44 UTC] PHP 12. Illuminate\Container\BoundMethod::callBoundMethod() /app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:39
[31-Aug-2020 15:53:44 UTC] PHP 13. Illuminate\Container\Util::unwrapIfClosure() /app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:95
[31-Aug-2020 15:53:44 UTC] PHP 14. Illuminate\Container\BoundMethod::Illuminate\Container{closure:/app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:35-39}() /app/vendor/laravel/framework/src/Illuminate/Container/Util.php:37
[31-Aug-2020 15:53:44 UTC] PHP 15. call_user_func_array:{/app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:37}() /app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:37
[31-Aug-2020 15:53:44 UTC] PHP 16. Illuminate\Database\Console\Migrations\MigrateCommand->handle() /app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:37
[31-Aug-2020 15:53:44 UTC] PHP 17. Illuminate\Database\Migrations\Migrator->usingConnection() /app/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:81
[31-Aug-2020 15:53:44 UTC] PHP 18. Illuminate\Database\Console\Migrations\MigrateCommand->Illuminate\Database\Console\Migrations{closure:/app/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:63-81}() /app/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:541
[31-Aug-2020 15:53:44 UTC] PHP 19. Illuminate\Database\Migrations\Migrator->run() /app/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:72
[31-Aug-2020 15:53:44 UTC] PHP 20. Illuminate\Database\Migrations\Migrator->requireFiles() /app/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:104
[31-Aug-2020 15:53:44 UTC] PHP 21. Illuminate\Filesystem\Filesystem->requireOnce() /app/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:482
Symfony\Component\ErrorHandler\Error\FatalError
Cannot declare class CreateTwoFactorAuthenticationsTable, because the name is already in use`
It has been fixed in the latter version.