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!

user3787031
  • 177
  • 1
  • 3
  • 12
  • 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!) – Vincent Buscarello Aug 31 '18 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. – user3787031 Aug 31 '18 at 21:08
  • Can you share a fuzzed up version? – Vincent Buscarello Aug 31 '18 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? – user3787031 Aug 31 '18 at 23:03
  • 1
    just marking the json as code with back ticks – Vincent Buscarello Sep 04 '18 at 21:09
  • I've just decided to start from scratch. I wasn't too far along and I could recreate the data pretty quickly with a script. – user3787031 Sep 05 '18 at 22:52

0 Answers0