0

How to fix django.db.utils.ProgrammingError: relation "some_object" does not exist? I saw lots of topic on this platform to related this error, but won't able to fix it in my case. In my case means, I am working on django and I have the postgresql database and It's working well but whenever I took pull request from git(where other person is working) and run the migration then I am getting this error. below is some links that I had tried

  1. https://stackoverflow.com/a/33055243/11360069 I just try but not working
  2. https://stackoverflow.com/a/46697898/11360069
  3. ./manage.py migrate --fake default
  4. https://stackoverflow.com/a/29672770/11360069
  5. python manage.py migrate --run-syncdb and python manage.py migrate --fake appname
  6. python manage.py migrate --fake, python manage.py migrate --fake--initial, python manage.py migrate

Only one way is working for me when I had create a new database and applying migration. But I am not sure that what will happen if, if I'll update this code on server then it will show same error then we can't delete or change the exiting database.

Kwall
  • 549
  • 4
  • 15
  • You probably have some missing migration files, try `makemigrations` and generate migration files again. – Sajad Mar 10 '21 at 08:16
  • @Sajad I tried that too but not working – Kwall Mar 10 '21 at 08:20
  • Did you remove existing migration files and try on a new database? – Sajad Mar 10 '21 at 08:22
  • @Sajad Yes I removed and getting same error. Ya it's working on new database(localhost) but if we are merging on server side code then we can't change the database because lots of users are there in that database. – Kwall Mar 10 '21 at 08:51
  • Out of interest are you the only developer or is this a case of migration dependency getting out of whack when multiple people create mergeable, but out of order migrations? – Trent Mar 11 '21 at 00:39
  • @Trent yes there are two people also working on same project. Am I ignore this error or is there any solution that we can apply? – Kwall Mar 11 '21 at 15:05
  • Chances are you'll need to sniff out references to "some_object" and figure out where it is in the migrations dependency. Only once you know where it is being referenced BEFORE it's created will you know how to solve it. It normally means going back and hacking old migrations or reordering migrations from your current DB migration position to your current git commit – Trent Mar 12 '21 at 05:44

0 Answers0