dumpdata/loaddata: issues with memberships and subscriptions
Currently it is not possible to use a dump created via dumpdata
as the source for loaddata
.
This procedure would be helpful for migrating data between databases with different engines.
stadtctl dumpdata --natural-primary --natural-foreign --exclude sessions --exclude admin.logentry --exclude contenttypes.contenttype --exclude auth.permission >out.json
# change database (and/or engine)
stadtctl loaddata --format=json - <out.json
Current problems:
- implicit group membership: An existing group with a non-null
gestalt_created
field seems to implicitly create a group membership. Thus the group membership (exported bydumpdata
) cannot be loaded, since it was already created after loading the group. - implicit subscription: An existing group membership seems to implicitly create a subscription. Thus the subscription (exported by
dumpdata
) cannot be loaded, since it was already created after loading the group membership. - group slugs: if the group slug in the input data is non-empty (e.g. "foo"), then it is imported as "foo-1". A null slug leads to the expected result (the slugified title of the group without any numeric suffix). Maybe there is some kind of uniqueness validation that accidentally takes the data being imported into account?
Or maybe dumpdata/loaddata is just not an appropriate tool for data transfer?