2022-07-20 05:34:21 +00:00
|
|
|
from unittest import mock
|
2022-07-02 17:55:37 +00:00
|
|
|
|
2022-07-20 05:34:21 +00:00
|
|
|
from django.db import connection, migrations
|
2014-03-14 17:34:49 +00:00
|
|
|
|
2015-04-04 16:10:26 +00:00
|
|
|
try:
|
|
|
|
from django.contrib.postgres.operations import (
|
2019-10-18 09:08:50 +00:00
|
|
|
BloomExtension,
|
|
|
|
BtreeGinExtension,
|
|
|
|
BtreeGistExtension,
|
|
|
|
CITextExtension,
|
2017-07-01 13:30:34 +00:00
|
|
|
CreateExtension,
|
|
|
|
CryptoExtension,
|
|
|
|
HStoreExtension,
|
|
|
|
TrigramExtension,
|
|
|
|
UnaccentExtension,
|
2015-04-04 16:10:26 +00:00
|
|
|
)
|
|
|
|
except ImportError:
|
2022-07-20 05:34:21 +00:00
|
|
|
BloomExtension = mock.Mock()
|
|
|
|
BtreeGinExtension = mock.Mock()
|
|
|
|
BtreeGistExtension = mock.Mock()
|
|
|
|
CITextExtension = mock.Mock()
|
|
|
|
CreateExtension = mock.Mock()
|
|
|
|
HStoreExtension = mock.Mock()
|
|
|
|
TrigramExtension = mock.Mock()
|
|
|
|
UnaccentExtension = mock.Mock()
|
2020-07-26 21:29:05 +00:00
|
|
|
needs_crypto_extension = False
|
|
|
|
else:
|
2020-07-31 10:38:09 +00:00
|
|
|
needs_crypto_extension = (
|
|
|
|
connection.vendor == "postgresql" and not connection.features.is_postgresql_13
|
|
|
|
)
|
2015-04-04 16:10:26 +00:00
|
|
|
|
2014-03-14 17:34:49 +00:00
|
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
operations = [
|
2020-05-14 04:33:00 +00:00
|
|
|
BloomExtension(),
|
2016-08-08 03:15:08 +00:00
|
|
|
BtreeGinExtension(),
|
2017-07-01 13:30:34 +00:00
|
|
|
BtreeGistExtension(),
|
2017-04-25 22:49:29 +00:00
|
|
|
CITextExtension(),
|
2016-04-25 23:30:48 +00:00
|
|
|
# Ensure CreateExtension quotes extension names by creating one with a
|
|
|
|
# dash in its name.
|
|
|
|
CreateExtension("uuid-ossp"),
|
2020-07-26 21:29:05 +00:00
|
|
|
# CryptoExtension is required for RandomUUID() on PostgreSQL < 13.
|
2022-07-20 05:34:21 +00:00
|
|
|
CryptoExtension() if needs_crypto_extension else mock.Mock(),
|
2014-03-14 17:34:49 +00:00
|
|
|
HStoreExtension(),
|
2015-06-05 16:37:48 +00:00
|
|
|
TrigramExtension(),
|
2014-09-05 20:53:11 +00:00
|
|
|
UnaccentExtension(),
|
2014-03-14 17:34:49 +00:00
|
|
|
]
|