在Laravel中创建用户表

I have some trouble with the laravel's users table. I already deleted those default table long time ago. And now I am trying to use Auth but I can't register. because there is no table in the database. But also i can't create table with php artisan migrate. because I already deleted those migration tables. So I want create those tables once more. But I couldn't find the default files.

And make:auth is doesn't bring the table... I need to recreate it by myself. I remember there two diffrent tables back then one is users and reset password? Do anyone know where can I get thoese tables again?

Just run these commands

php artisan make:migration create_users_table
php artisan make:migration create_password_resets_table

In your migration create_users_table

public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('email')->unique();
            $table->timestamp('email_verified_at')->nullable();
            $table->string('password');
            $table->rememberToken();
            $table->timestamps();
        });
    }

In your migration create_password_resets_table

 public function up()
    {
        Schema::create('password_resets', function (Blueprint $table) {
            $table->string('email')->index();
            $table->string('token');
            $table->timestamp('created_at')->nullable();
        });
    }

after that run

php artisan migrate:refresh

PS: This will reset your database Or just run

php artisan migrate

EDIT: If facing error 1071 Specified key was too long; max key length is 767 bytes

In your AppServiceProvider.php add this

use Illuminate\Support\Facades\Schema; //this

public function boot()
{
    Schema::defaultStringLength(191); //this
}

You should run below command:

php artisan make:auth

then run below command

php artisan migrate

You can retrieve those deleted migrations from laravel repository : https://github.com/laravel/laravel/tree/master/database/migrations

2014_10_12_000000_create_users_table.php :

<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('email')->unique();
            $table->timestamp('email_verified_at')->nullable();
            $table->string('password');
            $table->rememberToken();
            $table->timestamps();
        });
    }
    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}

2014_10_12_100000_create_password_resets_table.php :

<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePasswordResetsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('password_resets', function (Blueprint $table) {
            $table->string('email')->index();
            $table->string('token');
            $table->timestamp('created_at')->nullable();
        });
    }
    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('password_resets');
    }
}