当前位置:网站首页>数据库迁移报错解决
数据库迁移报错解决
2022-07-27 05:02:00 【pink_Pig___】
更改模型类时:
在遇到需要更改模型类的时候
删除数据库中的表和migrations中的迁移文件
重新进行迁移
先执行
python manage.py makemigrations
执行完的信息
-Create model User
再执行python manage.py migrate 就会报错
No migrations to apply
我们在进行迁移文件时
一共会生成三方文件,迁移文件、数据库中的表以及迁移信息的记录
这里是我之前写的一个项目拿来给大家举例
我们打开数据库
迁移打开django_migrations表会看到之前的迁移记录

因为这条user迁移记录数据库会以为我们已经迁移完成不会在进行迁移操作
删除完再次执行python manage.py migrate就能够迁移成功了
最后记住:
迁移文件、数据库中的表以及迁移信息的记录这三方删除的时候缺一不可,缺少任何一方都会报错。
边栏推荐
- Differences and examples between internal classes and static internal classes
- Notes Series docker installation PostgreSQL 14
- 李宏毅机器学习组队学习打卡活动day04---深度学习介绍和反向传播机制
- 如何查看导师的评价
- Scientific Computing Library - numpy
- SQL database → constraint → design → multi table query → transaction
- 简化JDBC的MyBits框架
- 李宏毅机器学习组队学习打卡活动day05---网络设计的技巧
- Quoted popular explanation
- Differences among bio, NiO and AIO
猜你喜欢

JVM上篇:内存与垃圾回收篇三--运行时数据区-概述及线程

JVM Part 1: memory and garbage collection part 5 -- runtime data area virtual machine stack

String class

JVM上篇:内存与垃圾回收篇十一--执行引擎

The difference between strlen and sizeof

B1021 single digit statistics

Database design - relational data theory (ultra detailed)

李宏毅机器学习组队学习打卡活动day06---卷积神经网络

A math problem cost the chip giant $500million

BIO、NIO、AIO区别
随机推荐
numpy 数据类型转化
The receiver sets the concurrency and current limit
Basic operation of vim
BIO、NIO、AIO区别
Static and final keyword learning demo exercise
Localdatetime and zoneddatetime
数据库连接池&&Druid使用
消息可靠性处理
DBUtils
JVM Part 1: memory and garbage collection part 12 -- stringtable
秒杀系统设计
JVM上篇:内存与垃圾回收篇十--运行时数据区-直接内存
JVM上篇:内存与垃圾回收篇二--类加载子系统
B1031 check ID card
B1023 group minimum
Database connection pool & Druid usage
Derivation and explanation of PBR physical illumination calculation formula
B1023 组个最小数
SQL数据库→约束→设计→多表查询→事务
Could not autowire. No beans of ‘userMapper‘ type found.