django python manage.py migrate 后报错字段长度超了 django.db.utils.OperationalError: (1118 'Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535.
现象:
在models.py 将CharField字段的maxlength=修改后,执行ython manage.py migrate 报错django.db.utils.OperationalError: (1118 'Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs')
我的触发操作 :
models.CharField(max_length=5120 改为 models.CharField(max_length=8192 然后就开始报错,再改回去5120仍然报错 ,无法恢复。
storage overhead, check the manual. You have to change some columns to TEXT or BLOBs')
django.db.utils.OperationalError: (1118, 'Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs')
报错
django.db.utils.OperationalError: (1118, 'Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes
storage overhead, check the manual. You have to change some columns to TEXT or BLOBs')
解决方案:
找到最近改的CharField 字段,maxlength 长度超过CharField 允许值“”的修正后,将之前makemigrations生成的临时缓存文件删除,再更改字段即可。
步骤一、修改正models.py CharField字段
然后重新makemigrations migrate ?
你会发现,依然给你抛这个错误
NO NO NO ....
步骤二、删除之前CharField不支持的maxlength时, python manage.py makemigrations 生成的 项目名/migrations/xxxxx.py 字段变更记录文件
步骤三、 再次重新python manage.py makemigrations 生成字段变动文件python manage.py migrate 向数据库提交成功!!!
发现:我的models.CharField(max_length 最多支持7159 ,7160就会提交失败了,这个值哪来的呢?
看了这个链接也没有搞明白,朋友圈里大佬指教指教吧.....
https://blog.csdn.net/yinjinshui/article/details/102496340
我的数据库
mysql> show create database monitor_test; +--------------+--------------------------------------------------------------------------+ | Database | Create Database | +--------------+--------------------------------------------------------------------------+ | monitor_test | CREATE DATABASE `monitor_test` /*!40100 DEFAULT CHARACTER SET utf8mb4 */ | +--------------+--------------------------------------------------------------------------+ 1 row in set (0.00 sec) mysql>
posted on 2023-07-11 20:30 zhangmingda 阅读(388) 评论(0) 编辑 收藏 举报
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具