laravel 5.6 error in migration

1

I try to create a login in laravel 5.6 and at the time of making the migration I get the following error

    
asked by leonaidass 16.04.2018 в 07:26
source

2 answers

1

Surely your version of MySQL is less than 5.7; then in the fields of index type the length is not specified, you can solve it in the following ways:

  • Open the file called AppServiceProvider.php and place the following instruction in the boot method
  •   

    Schema :: defaultStringLength (191);

    And at the same time in the upper part just below the namespace App \ Providers, it also declares this line of code

      

    use Illuminate \ Support \ Facades \ Schema;

  • If it becomes possible to update your version of MySQL to 5.7
  • Keep working with your regular version of MySQL and each field that is declared as index or unique also within the length they should have; as follows:
  • php <?php public function up() { Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('email',100)->unique(); $table->string('password'); $table->rememberToken(); $table->timestamps(); }); }

      

    In the previous code, notes as in the line of the string email I pass   after the name also a length of 100

        
    answered by 16.04.2018 в 12:07
    0

    Note: you should upload code in text to make it easier.

    The error occurs in certain database engines due to the character set and coding, depending on the coding, each char can occupy 1, 2, or 4 bytes (utf8, utf8mb4) and this makes the maximum limit reach type varchar to define the unique key.

    On each line that says $table->string try adding the maximum number of characters (190)

    for example:

    $table->string('name', 190);
    

    more info: link

        
    answered by 16.04.2018 в 08:49