Wagtail migration doesn't respect --run-syncdb
See original GitHub issueRunning migrate
under wagtail creates tables with data despite using --run-syncdb
.
As a result of this, it is difficult to load a database dump via ./manage.py loaddata
. It fails because some tables are not empty.
There are open tickets where people come up with unnecessary complicated hacks to load data:
This would all become quite simple if the wagtail migration would respect --run-syncdb
Issue Summary
When running ./manage.py migrate --run-syncdb
, some wagtail tables are initialized with data which they should not.
At least the following tables are not empty:
- " wagtailcore_page"
- " wagtailcore_site"
- " wagtailcore_groupcollectionpermission"
- " wagtailcore_grouppagepermission"
Steps to Reproduce
- Start a new project with
wagtail start myproject
- Run
./manage.py migrate --run-syncsb
- Inspect tables listed above
Expected Behaviour
When running migrations with --run-syncdb
on an empty database, empty tables should be created without any data
Technical details
- Python version: 3.7.5
- Django version: 3.0.4
- Wagtail version: 2.8
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5
Top Results From Across the Web
problem: Table doesn't exist( python manage.py migrate)
I dropped some table related to an app. and again tried the syncdb command. python manage.py migrate.
Read more >[Solved]-Django syncdb not running custom SQL-django
Coding example for the question Django syncdb not running custom SQL-django. ... Initial data sql doesn't get run for South-managed applications.
Read more >migrate --run-syncdb doesn't work when specifying a database
When running 'python manage.py migrate --run-syncdb polls' I get the error "CommandError: App 'polls' does not have migrations.", while I expected an sqlite- ......
Read more >Migrating your Django Project to Heroku - Real Python
In this tutorial, we'll be taking a simple local Django project, backed by a MySQL database, and converting it to run on Heroku....
Read more >Django and Wagtail Migrations - consumerfinance.gov - CFPB
To automatically generate a schema migration, run the following, editing it to give your migration a name that briefly describes the change(s) you're...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
./manage.py migrate
followed by./manage.py flush
should give you an empty database with all tables intact.@gasman On my side I am trying to migrate from SQLite3 to a PostgreSQL database, so I followed this guide: https://gist.github.com/sirodoht/f598d14e9644e2d3909629a41e3522ad
It does say to run it with
--run-syncdb
option, which in my mind is the way to create empty tables which will be filled up with theloaddata
command later on.I ran into a separate issue (I believe related to #6069) but after configuring my PostgreSQL database as default in my
base.py
Django settings file, I ran into another error:Indeed:
I deleted the Page instance but still running into a content type error when running
loaddata
:And can’t find a way to delete the initial content load from the shell:
So I’ve tried to dump the data exluding content types
python manage.py dumpdata --exclude=contenttypes --exclude=auth.Permission > dumpdata_nocontent.json
as a workaround (suggested here) but no luck:Anyway, I digress…
What’s your proposed way to be able to create tables but not load initial data? Better yet, what your proposed way for migrating data from one database to another?
Thanks a lot.