php artisan migrate SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'password_resets' already exists 1

php artisan migrate SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘password_resets’ already exists

   if(!Schema::hasTable('users')){
    Schema::create('users', function (Blueprint $table) {
        $table->increments('id');
        $table->string('name');
        $table->string('email')->unique();
        $table->string('password');
        $table->rememberToken();
        $table->timestamps();
        });
  } 
      above see this condition and save this and run php artisan migrate
 command and your table show in db

Here is what the above code is Doing:
1. First, we check if the users table exists. If it does, we don’t do anything.
2. If the users table doesn’t exist, we create it.
3. We use the increments method to create an auto-incrementing primary key.
4. We use the string method to create a string column.
5. We use the unique method to create a unique index on the email column.
6. We use the rememberToken method to create a remember_token column for
remembering users in our application.
7. We use the timestamps method to create the created_at and updated_at columns.

Similar Posts