diff options
| author | Rust Saiargaliev <fly.amureki@gmail.com> | 2022-08-10 14:42:53 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-10 13:42:53 +0200 |
| commit | 8403da3696730f8b9e7d2ad20c920fcd7c52b62c (patch) | |
| tree | 2d286265f00d2383371c5fbdc9d5b3153f6261ed | |
| parent | 721706f4c40f4970f57647368d45f49e20028628 (diff) | |
Fixed #28975 -- Made PostGIS backend skip extension creation if installed.
| -rw-r--r-- | django/contrib/gis/db/backends/postgis/base.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/django/contrib/gis/db/backends/postgis/base.py b/django/contrib/gis/db/backends/postgis/base.py index 87a30004a1..98c2813aa2 100644 --- a/django/contrib/gis/db/backends/postgis/base.py +++ b/django/contrib/gis/db/backends/postgis/base.py @@ -23,4 +23,7 @@ class DatabaseWrapper(Psycopg2DatabaseWrapper): super().prepare_database() # Check that postgis extension is installed. with self.cursor() as cursor: + cursor.execute("SELECT 1 FROM pg_extension WHERE extname = %s", ["postgis"]) + if bool(cursor.fetchone()): + return cursor.execute("CREATE EXTENSION IF NOT EXISTS postgis") |
