diff options
| author | Nick Pope <nick.pope@flightdataservices.com> | 2020-07-26 22:29:05 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-07-28 07:21:16 +0200 |
| commit | 628c4a26eee93417bb7161aa393dffb3f4c146b2 (patch) | |
| tree | 6e7fb7f3133352983088381dd712bcc9de4e742b /tests/postgres_tests/migrations | |
| parent | 83fbaa92311dd96e330496a0e443ea71b9c183e2 (diff) | |
Refs #27996 -- Doc'd no extension required for RandomUUID() on PostgreSQL 13+.
https://www.postgresql.org/docs/13/functions-uuid.html
https://www.postgresql.org/docs/13/pgcrypto.html#id-1.11.7.34.10.5
Diffstat (limited to 'tests/postgres_tests/migrations')
| -rw-r--r-- | tests/postgres_tests/migrations/0001_setup_extensions.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/tests/postgres_tests/migrations/0001_setup_extensions.py b/tests/postgres_tests/migrations/0001_setup_extensions.py index 5064f7ff99..3775295f25 100644 --- a/tests/postgres_tests/migrations/0001_setup_extensions.py +++ b/tests/postgres_tests/migrations/0001_setup_extensions.py @@ -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(), |
