【发布时间】:2020-09-25 22:12:35
【问题描述】:
以下:是我会收到的错误吗(请注意,如果它不是 users 表,它是 failed_jobs 或 reset_password 表。大多数问题来自 laravel 自动生成的表。是的,我确实尝试过 PHP artisan迁移:重置,从本地主机删除表,我什至删除了数据库本身)
Migrating: 2014_10_12_100000_create_password_resets_table
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 `password_resets` add index `password_resets_email_index`(`email`))
at C:\xampp\htdocs\project1\project\seed\vendor\laravel\framework\src\Illuminate\Database\Connection.php:671
667| // If an exception occurs when attempting to run a query, we'll format the error
668| // message to include the bindings with SQL, which will make this exception a
669| // lot more helpful to the developer instead of just the database's errors.
670| catch (Exception $e) {
> 671| throw new QueryException(
672| $query, $this->prepareBindings($bindings), $e
673| );
674| }
675|
1 C:\xampp\htdocs\project1\project\seed\vendor\laravel\framework\src\Illuminate\Database\Connection.php:464
PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes")
2 C:\xampp\htdocs\project1\project\seed\vendor\laravel\framework\src\Illuminate\Database\Connection.php:464
PDOStatement::execute()
这就是数据库/迁移/create_reset_password_table 到目前为止的样子。
class CreatePasswordResetsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('password_resets', function (Blueprint $table) {
$table->string('email')->index();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('password_resets');
}
}
提前感谢您的所有帮助! :)
【问题讨论】:
标签: laravel laravel-7 laravel-migrations