|
@@ -1,6 +1,6 @@
|
|
|
from unittest import mock
|
|
|
|
|
|
-from django.db import migrations
|
|
|
+from django.db import connection, migrations
|
|
|
|
|
|
try:
|
|
|
from django.contrib.postgres.operations import (
|
|
@@ -14,10 +14,12 @@ except ImportError:
|
|
|
BtreeGistExtension = mock.Mock()
|
|
|
CITextExtension = mock.Mock()
|
|
|
CreateExtension = mock.Mock()
|
|
|
- CryptoExtension = mock.Mock()
|
|
|
HStoreExtension = mock.Mock()
|
|
|
TrigramExtension = mock.Mock()
|
|
|
UnaccentExtension = mock.Mock()
|
|
|
+ needs_crypto_extension = False
|
|
|
+else:
|
|
|
+ needs_crypto_extension = not connection.features.is_postgresql_13
|
|
|
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
@@ -30,7 +32,8 @@ class Migration(migrations.Migration):
|
|
|
# Ensure CreateExtension quotes extension names by creating one with a
|
|
|
# dash in its name.
|
|
|
CreateExtension('uuid-ossp'),
|
|
|
- CryptoExtension(),
|
|
|
+ # CryptoExtension is required for RandomUUID() on PostgreSQL < 13.
|
|
|
+ CryptoExtension() if needs_crypto_extension else mock.Mock(),
|
|
|
HStoreExtension(),
|
|
|
TrigramExtension(),
|
|
|
UnaccentExtension(),
|