Code

Opened 6 years ago

Closed 6 years ago

#7078 closed (duplicate)

dumpdata conflicts with syncdb entries for new installations

Reported by: chazen@… Owned by: nobody
Component: Core (Serialization) Version: master
Severity: Keywords: dumpdata loaddata syncdb app_label model unique
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

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:

  1. On the server:
    python manage.py dumpdata > server_live_data.json
    
  2. 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 )

Attachments (0)

Change History (1)

comment:1 Changed 6 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #6121.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.