dumpdata conflicts with syncdb entries for new installations
|Reported by:||chazen@…||Owned by:||nobody|
|Severity:||Keywords:||dumpdata loaddata syncdb app_label model unique|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I have a running django site on a server. I want to copy the server data to a new machine with a new installation, on which I will do testing and development. To do this, I must copy the data in the server's database to the testing machine.
I do the following steps:
- On the server:
python manage.py dumpdata > server_live_data.json
- On the new testing installation:
% python manage.py syncdb ... You just installed Django's auth system, which means you don't have any superusers defined. Would you like to create one now? (yes/no): no ... % python manage.py loaddata server_live_data.json Installing json fixture 'server_live_data' from absolute path. Problem installing fixture 'server_live_data.json': columns app_label, model are not unique
The problem is that the data dumped by "loaddata" includes entries like "auth.permission" and "contenttypes.contenttype". However, these entries are already present in the new database from running "syncdb". The "syncdb" step cannot be skipped, because it creates the empty tables that "loaddata" needs.
One can work around this by manually editing the JSON or XML from dumpdata to remove "contenttypes", "auth", or any other entries added by syncdb. A more robust solution would be an option to loaddata such as "--clobber" to allow it to overwrite data already present in the tables.
(see also this thread: http://groups.google.com/group/django-users/msg/562c6350b2ab13f8 )