0
0
mirror of https://github.com/django/django.git synced 2024-11-29 14:46:18 +01:00

Fixed #28975 -- Made PostGIS backend skip extension creation if installed.

This commit is contained in:
Rust Saiargaliev 2022-08-10 14:42:53 +03:00 committed by GitHub
parent 721706f4c4
commit 8403da3696
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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")