问题
我有一个空的(迁移的)Postgres数据库,我想将数据从我的SQLite数据库移动到其中。
我已经尝试过的方法
I export with
./manage.py dumpdata --exclude auth.permission --exclude contenttypes --natural-foreign
and consequtively load the data into the postgres db with
./manage.py loaddata
.The problem here is that wagtail requires the contenttypes and I get a runtime error
FooPage matching query does not exist.
at
/wagtail/wagtailcore/models.py:639 return content_type.get_object_for_this_type(id=self.id)
Don't exclude
contenttypes
withdumpdata
. Now theloaddata
command fails with anIntegrityError
:Key ... already exists
.I have tried to remove all
ContentType
model objects before loading in the data so that it doesn't whine about duplicate keys. While that works when using the sqlite db, it fails on the postgres db with anIntegrityError
Key (id)=(1) is still referenced from table "wagtailcore_page".
使用版本
- django 1.11.9
- wagtail 1.12.3
- python 3.5
相关内容
--natural-foreign
命令进行dumpdata
,请参阅文档。 - rafalmp