一,遷移指令
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表,否則彙報如下錯誤:
正确的流程如下:
python manage.py migrate auth --database=db2
python manage.py migrate contenttypes --database=db2
python manage.py migrate appname2 --database=db2