一,迁移命令
db1:django的一个数据库
db2:django的另一个数据库
appname1:使用db1的app
appname2:使用db2的app
python manage.py migrate appname2 --database=db2
二,迁移过程中的问题
"Error creating new content types. Please make sure contenttypes "
RuntimeError: Error creating new content types. Please make sure contenttypes is migrated before trying to migrate apps individually.
这是因为db2中没有django数据库基本信息表,需要把contentype表也迁移到db2中,同时contentype有依赖于auth表,所以需要先迁移auth表,否则汇报如下错误:
django.db.utils.ProgrammingError: (1146, "Table 'xxxx.auth_permission' doesn't exist")
正确的流程如下:
python manage.py migrate auth --database=db2
python manage.py migrate contenttypes --database=db2
python manage.py migrate appname2 --database=db2
来源:CSDN
作者:yrx0619
链接:https://blog.csdn.net/yrx0619/article/details/103930012