The issue
I have an empty (migrated) postgres database to which I want to move the data from my sqlite database.
What I've tried
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
with dumpdata
. Now the loaddata
command fails with an IntegrityError
: 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 an IntegrityError
Key (id)=(1) is still referenced from table "wagtailcore_page".
Used versions
Related
Problems with contenttypes when loading a fixture in Django
Steps for Connecting SQLite to PostgreSQLStep 1: Create SQLite DB Dumpdata Backup. Step 2: Generate a Postgres DB and User. Step 3: Configure Settings.py. Step 4: Import Required Fixture via Loaddata from SQLite to PostgreSQL.
Using CData Sync, you can replicate SQLite data to PostgreSQL. To add a replication destination, navigate to the Connections tab. Click Add Connection.
No. pgAdmin is meant for Postgres, not for SQLite. The two are completely incompatible on that level of access.
With pgloader you can execute command instructions to load data from SQLite into Postgres.
Install on OSX with Homebrew:
brew install pgloader
Create a script file. Eg migrate.script
:
load database
from sqlite:///path/to/db.sqlite3
into postgresql:///yourpostgresdbname
with include drop, create tables, create indexes, reset sequences
set work_mem to '16MB', maintenance_work_mem to '512 MB';
Run it:
pgloader migrate.script
I did a testdrive with a SQLite database containing a minimal Wagtail project (some pages, revisions and images) and it worked perfectly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With