当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
浅谈Numpy中的shape、reshape函数的区别
Sudoku | Backtrack-7
6个规则去净化你的代码
Leetcode 93 IP addresses
Word第一页不要页眉怎么设置?设置Word首页不要页眉方法教程
TF中使用zeros(),ones(), fill()方法生成数据
埃氏筛选法:统计素数个数
CVPR22 Oral | shunt through multi-scale token polymerization from attention, code is open source
Definition and Basic Operations of Sequence Tables
题解:Edu Codeforces 109(div2)
fixed investment fund
AI Knows Everything: Building and Deploying a Sign Language Recognition System from Zero
FET Mosfet Leiditech corresponds to Infineon Infineon
单元测试
NetCore路由的Endpoint模式
cad图纸怎么复制到word文档里面?Word里插CAD图怎么弄?
The round functions in the np, ceil function and floor function
《强化学习周刊》第57期:DL-DRL、FedDRL & Deep VULMAN
LeetCode26:删除有序数组中的重复项
[corctf 2022] 部分