MCPcopy
hub / github.com/django/django / has_table

Method has_table

django/db/migrations/recorder.py:56–67  ·  view source on GitHub ↗

Return True if the django_migrations table exists.

(self)

Source from the content-addressed store, hash-verified

54 return self.Migration.objects.using(self.connection.alias)
55
56 def has_table(self):
57 """Return True if the django_migrations table exists."""
58 # If the migrations table has already been confirmed to exist, don't
59 # recheck it's existence.
60 if self._has_table:
61 return True
62 # It hasn't been confirmed to exist, recheck.
63 with self.connection.cursor() as cursor:
64 tables = self.connection.introspection.table_names(cursor)
65
66 self._has_table = self.Migration._meta.db_table in tables
67 return self._has_table
68
69 def ensure_schema(self):
70 """Ensure the table exists and has the correct schema."""

Callers 4

ensure_schemaMethod · 0.95
applied_migrationsMethod · 0.95
test_has_table_cachedMethod · 0.95
migrateMethod · 0.80

Calls 2

cursorMethod · 0.80
table_namesMethod · 0.80

Tested by 1

test_has_table_cachedMethod · 0.76