Search code examples
phplaravelweblaravel-5.3

I having error migrating my second table in laravel


I am having a problem while running php artisan migrate on my second table after running my first users table in laravel. When I run the second table migration, I get this error:

[PDOException] SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'users' already exists


Solution

  • php artisan migrate run all the migrations inside database/migrations folder. So, first you migrated the users table and then you created a new second table migration and ran this command so laravel tried to migrate the users migration again which already exists inside your database and this error is being thrown.

    You need to run:

    php artisan migrate:refresh
    

    It'll will roll back all of your migrations and then execute the migrate command.