Home > Software engineering >  I am getting error on Laravel Table Migrate
I am getting error on Laravel Table Migrate

Time:12-22

I am new to laravel, I am beginner, I have a problem when I run php artisan migrate in laravel table.

C:\wamp64\www\my-blog>php artisan migrate
Migrating: 2014_10_12_000000_create_users_table

   Illuminate\Database\QueryException

  SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'users' already exists (SQL: create table `users` (`id` bigint unsigned not null auto_increment primary key, `name` varchar(255) not null, `email` varchar(255) not null, `email_verified_at` timestamp null, `password` varchar(255) not null, `remember_token` varchar(100) null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')

  at C:\wamp64\www\my-blog\vendor\laravel\framework\src\Illuminate\Database\Connection.php:703
    699▕         // If an exception occurs when attempting to run a query, we'll format the error
    700▕         // message to include the bindings with SQL, which will make this exception a
    701▕         // lot more helpful to the developer instead of just the database's errors.
    702▕         catch (Exception $e) {
  ➜ 703▕             throw new QueryException(
    704▕                 $query, $this->prepareBindings($bindings), $e
    705▕             );
    706▕         }
    707▕     }

  1   C:\wamp64\www\my-blog\vendor\laravel\framework\src\Illuminate\Database\Connection.php:492
      PDOException::("SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'users' already exists")

  2   C:\wamp64\www\my-blog\vendor\laravel\framework\src\Illuminate\Database\Connection.php:492
      PDOStatement::execute()

CodePudding user response:

I think the error message is pretty clear, however you have a few different ways to solve it.

  1. Rerun the migrations:

    php artisan migrate:refresh

  2. Rolling back your migration:

    php artisan migrate:rollback

When you use PHPStorm you have a database tab on the right side of your window, there you can manually delete the user table and then run php artisan migrate - however I recommend to use 1. or 2. and not do it manually

CodePudding user response:

Just Run

php artisan migrate:rollback

  • Related