Skip to content

Commit

Permalink
Merge pull request #2057 from anehx/fix-prefix-migration
Browse files Browse the repository at this point in the history
fix(migrations): make app prefix migration language independent
  • Loading branch information
anehx authored Aug 31, 2023
2 parents 68492af + 2f3a5d3 commit fe85225
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.core.management.base import BaseCommand
from django.db import connection
from django.db.utils import ProgrammingError
from psycopg2.errors import UndefinedTable


class Command(BaseCommand):
Expand Down Expand Up @@ -35,8 +36,10 @@ def _migration_needed(self):
try:
cursor.execute(query, params=None)
except ProgrammingError as e: # pragma: no cover
# happens only on initial migration for new project
if e.args[0].startswith('relation "django_migrations" does not exist'):
# Happens only on initial migration for new project.
# `e.__cause__` contains the underlying psycopg2 exception
# which is more specific than the django wrapper exception
if isinstance(e.__cause__, UndefinedTable):
return False
raise
if cursor.fetchone():
Expand Down

0 comments on commit fe85225

Please sign in to comment.