1

I'm having some trouble with migrating from SQLite3 to Postgres on Django. Essentially I'm following this thread (Django: What are the best practices to migrate a project from sqlite to PostgreSQL). There's been a similar error that I've used the TRUNCATE command on and got past, but now I'm hitting a duplicate key error for my own model.

The model client is a OnetoOne relationship with Django's built in user. It just asks for a few additional details like business type and join date. And the migration is coming up with an error. The client, primary key 1 is my superuser with code:

user = models.OneToOneField(User, on_delete=models.SET_NULL, null=True, blank=True)

And I'm getting this error:

django.db.utils.IntegrityError: Problem installing fixture 'C:\Users\*******\dump.json': Could not load clauses.Client(pk=1): duplicate key value violates unique constraint "clauses_client_clientusername_id_******_uniq"

Could someone point me the right way? Thanks!

6
  • 2
    Can you post your fixtures? Also, are you dropping data from the pg db entirely before trying to load fixtures into it? generally with fixtures thats a good practice (for local development only of course, not production!) Commented Aug 31, 2018 at 17:56
  • Unfortunately I don't think I can share the fixtures. Some of the test data has personal information. As for the dropping data, they are fresh pg databases that I created on pgAdmin 4. I dropped and recreated them between trials, so they should be fresh each time. Commented Aug 31, 2018 at 21:08
  • Can you share a fuzzed up version? Commented Aug 31, 2018 at 21:26
  • Sure I can try to blank out some of the info. Stupid question though, what's the protocol for sharing something like that on stackoverflow? Is a dropbox link acceptable? Commented Aug 31, 2018 at 23:03
  • 1
    just marking the json as code with back ticks Commented Sep 4, 2018 at 21:09

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.