jcadima
1/27/2017 - 7:05 PM

Fix error with php artisan migrate

Fix error with php artisan migrate

FOR laravel 5.4

http://stackoverflow.com/questions/23786359/laravel-migration-unique-key-is-too-long-even-if-specified

1) go to app/Providers/AppServiceProvider.php

2) import Schema:
use Illuminate\Support\Facades\Schema;
<?php

// RESULT: 
namespace App\Providers;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        //
        Schema::defaultStringLength(191);
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}

2) then you will be able to run migrations:
  
$ php artisan migrate