为什么我不能使用生成的名称进行迁移?

Why cant I use the generated name for a migration?

2018_04_19_095256_create_admins_table.php, 这是名字 当我 运行 命令 "php artisan make:migration... "

时生成

当我 运行 命令 "php artisan migrate" 时,它没有显示在我的数据库中 .

但是当我更改迁移的名称时 运行s。我改变了 "2018_04_19_095256_create_admins_table.php" 的迁移名称到 "2014_04_19_095256_create_admins_table.php".

另外 "2014_10_12_100000_create_password_resets_table.php" 没有显示在我的数据库中

有什么方法可以使用生成名称进行迁移?

迁移文件代码:

Migration table created successfully.

   Illuminate\Database\QueryException  : SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `admins` add unique `admins_email_unique`(`email`))

  at C:\xampp\htdocs\century\vendor\laravel\framework\src\Illuminate\Database\Connection.php:664
    660|         // If an exception occurs when attempting to run a query, we'll format the error
    661|         // message to include the bindings with SQL, which will make this exception a
    662|         // lot more helpful to the developer instead of just the database's errors.
    663|         catch (Exception $e) {
  > 664|             throw new QueryException(
    665|                 $query, $this->prepareBindings($bindings), $e
    666|             );
    667|         }
    668|

  Exception trace:

  1   PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes")
      C:\xampp\htdocs\century\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458

  2   PDOStatement::execute()
      C:\xampp\htdocs\century\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458

  Please use the argument -v to see more details.

进入位于 App/Providers 的 AppServiceProvider 并按如下方式编辑它

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;

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

注意我们添加了对Schema的使用,并在启动函数中添加了Schema::defaultStringLength。这将消除错误。