当前位置:网站首页>laravel table migration error [easy to understand]
laravel table migration error [easy to understand]
2022-08-09 23:13:00 【The whole stack programmer webmaster】
Hello everyone, meet again, I'm your friend Quanstack Jun.
error infomation:
Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error oraccess violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `users` add unique `users_email_unique`(`email`))at D:\WWW\test\vendor\laravel\framework\src\Illuminate\Database\Connection.php:664660| // If an exception occurs when attempting to run a query, we'll format the error661| // message to include the bindings with SQL, which will make this exception a662| // 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), $e666| );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")D:\WWW\test\vendor\laravel\framework\src\Illuminate\Database\Connection.php:4582 PDOStatement::execute()D:\WWW\test\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458Please use the argument -v to see more details.Solution: Index length & Mysql / MariaDB Laravel uses utf8mb4 encoding by default, which supports storing emojis in the database.If you are creating an index on a MySQL version lower than 5.7.7 or MariaDB version lower than 10.2.2, then you need to manually configure the default string length for database migrations.That is, call the Schema::defaultStringLength method in AppServiceProvider to configure it:
use Illuminate\Support\Facades\Schema;/** * Boot any application service * * @return void */public function boot(){Schema::defaultStringLength(191);}Publisher: Full-stack programmer, please indicate the source: https://javaforall.cn/105807.htmlOriginal link: https://javaforall.cn
边栏推荐
猜你喜欢

TF generates uniformly distributed tensor

同步锁synchronized追本溯源

Puyuan Jingdian turned losses into profits in the first half of the year, and high-end products continued to develop!Are you optimistic about "Huawei" in the instrument industry?
6个规则去净化你的代码

【云原生】4.2 DevOps 精讲篇

fixed investment fund

XXE-XML外部实体注入-知识点

DSPE-PEG-Silane, DSPE-PEG-SIL, phospholipid-polyethylene glycol-silane modified silica particles

万字总结:分布式系统的38个知识点

Simulation of Water Temperature Control System Based on Fuzzy PID Controller
随机推荐
Tensorflow中使用convert_to_tensor去指定数据的类型
论文解读(DropEdge)《DropEdge: Towards Deep Graph Convolutional Networks on Node Classification》
hdu 3341 Lost's revenge(dp+Ac自动机)
蓝牙模块的分类和对应的属性特点
万字总结:分布式系统的38个知识点
hdu 1503 Advanced Fruits(最长公共子序列的应用)
Ali Ermi: Without accept, can a TCP connection be established?
PMP每日一练 | 考试不迷路-8.8(包含敏捷+多选)
威纶通触摸屏制作自定义弹出窗口的具体方法(3种)
PHP 二维数组根据某个字段排序
必看设计干货|易知微设计师是怎么做标准可视化设计服务的?
Word第一页不要页眉怎么设置?设置Word首页不要页眉方法教程
supervisor 命令操作大全「建议收藏」
数独 | 回溯-7
【云原生】4.2 DevOps 精讲篇
Lyapp exponents and bifurcation diagrams for fractional chaotic systems
Word文档怎么输入无穷大符号∞
编程时请选择正确的输入法,严格区分中英文
Daily practice of PMP | Do not get lost in the exam -8.8 (including agility + multiple choice)
CVPR22 Oral | shunt through multi-scale token polymerization from attention, code is open source