search

Home  >  Q&A  >  body text

Laravel 5.4 php artisan migrate prompt table already exists

Execute when the database does not have any tables

php artisan migrate

After execution, there will only be two tables in the database: migrations, users

Execute again

php artisan migrate

There will be no new additions to the database. Solve.

我想大声告诉你我想大声告诉你2773 days ago448

reply all(2)I'll reply

  • 给我你的怀抱

    给我你的怀抱2017-05-16 16:49:03


    The length of the index exceeds mysql的限制,在migratebefore setting

    $table->string('email' , 32)->index();
    $table->string('token' , 128)->index();

    or smaller...

    reply
    0
  • 大家讲道理

    大家讲道理2017-05-16 16:49:03

    This is because 5.4 uses the utf8mb4 character set by default, in MySQL / MariaDB.

    https://laravel.com/docs/5.4/migrations#indexes

    Just install the sample modifications in the documentation.

    In AppServiceProvider.php, boot method, call Schema::defaultStringLength method

    
    // AppServiceProvider.php
    
    
    use Illuminate\Support\Facades\Schema;
    
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        Schema::defaultStringLength(191);
    }

    By the way, you can also enable the database's innodb_large_prefix configuration

    reply
    0
  • Cancelreply