How to troubleshoot Django errors when migrating sqlite database to postgres

Pubblicato il: 05 marzo 2022
sul canale di: John Solly
1,310
17

Overcome integrity, duplicate keys, and contenttype errors when attempting a database migration from sqlite to postgres for a Django project.

Troubleshooting

To overcome this error
django.db.utils.ProgrammingError: relation "blog_category" does not exist

Uncomment line in forms.py so that categories are not fetched before the table is created

To overcome this error
django.db.utils.IntegrityError: Problem installing fixture Could not load contenttypes.ContentType

Remove auto added contenttypes from django for loading data

$ python3 manage.py shell

from django.contrib.contenttypes.models import ContentType

ContentType.objects.all().delete()

If you run into this error:
Key (id)=(1) already exists

try commenting out pre-save methods (signals.py)

Timestamps
5:00 - Table does not exist
9:12 - Key already exists
10:43 - Another Key already exists error


In questa pagina del sito puoi guardare il video online How to troubleshoot Django errors when migrating sqlite database to postgres della durata di ore minuti seconda in buona qualità , che l'utente ha caricato John Solly 05 marzo 2022, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 1,310 volte e gli è piaciuto 17 spettatori. Buona visione!