【问题标题】:When I try to Migrating my Laravel database I get the error "alter table `users` add unique `users_email_unique`(`email`)"当我尝试迁移我的 Laravel 数据库时,我收到错误“alter table `users` add unique `users_email_unique`(`email`)”
【发布时间】:2020-01-07 04:26:22
【问题描述】:

当我尝试使用这个 cmd 命令迁移我的数据库表时,我的 Laravel 数据库迁移出现了一个问题:PHP artisan migrate 然后显示以下错误。

alter table `users` add unique `users_email_unique`(`email`)

我是否必须更改用户表格文件中的任何内容或是否有任何其他设置?

【问题讨论】:

  • 嘿@Gaurav Gupta 感谢好友,但现在在 pixlogix 的帮助下解决了
  • 只是为了解释而已。 :)
  • 是的,我检查了一下,感谢好友的帮助

标签: laravel-5


【解决方案1】:

信用:Lumen 5.6 Migrate Error Specified key was too long max key length is 767 bytes

use Illuminate\Support\Facades\Schema; //AppServiceProvider.php

public function boot(){
Schema::defaultStringLength(191);
}

【讨论】:

  • 嘿,哥们,谢谢你的回答,你能不能给我解释一下希望你不介意提前谢谢
  • 打开App/providers/AppServiceProvider.php,把代码“use Illuminate\Support\Facades\Schema;”在顶部,然后放入“Schema::defaultStringLength(191);”在 boot() 函数中
  • 非常感谢@pixlogix 它对我的工作祝你度过了愉快的一天
猜你喜欢
  • 2021-03-29
  • 1970-01-01
  • 1970-01-01
  • 2019-02-14
  • 2018-12-07
  • 2022-11-28
  • 1970-01-01
  • 2016-05-29
  • 2019-09-14
相关资源
最近更新 更多