-3

我正在运行 'php artisan migrate' 我收到了这个错误:

([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 users add unique users_email_unique(email))) 之后在AppServiceProvider.php

添加此代码

(使用 Illuminate\Support\Facades\Schema;和 Schema::defaultStringLength(191);)

现在我得到另一个错误

(PHP 致命错误:无法使用 Illuminate\Support\Facades enter code here\Schema 作为 Schema,因为该名称已在第 7 行的 C:\xampp\htdocs\projects\app\Providers\AppServiceProvider.php 中使用)

以下是 AppServiceProvider.php 代码

<?php


namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use mysql_xdevapi\Schema;
use Illuminate\Support\Facades\Schema;

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()`enter code here`
    {
        //
    }
}
4

1 回答 1

0

我想您会收到此错误,因为您尝试导入 2 个Schema类。

尝试use mysql_xdevapi\Schema;AppServiceProvider.

于 2019-05-21T06:47:36.413 回答