summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
Diffstat (limited to 'django')
-rw-r--r--django/contrib/postgres/indexes.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/django/contrib/postgres/indexes.py b/django/contrib/postgres/indexes.py
index 677c63b4a2..3b77b97f3e 100644
--- a/django/contrib/postgres/indexes.py
+++ b/django/contrib/postgres/indexes.py
@@ -1,7 +1,7 @@
from django.db.models import Index
from django.utils.functional import cached_property
-__all__ = ['BrinIndex', 'GinIndex', 'GistIndex']
+__all__ = ['BrinIndex', 'GinIndex', 'GistIndex', 'HashIndex']
class PostgresIndex(Index):
@@ -98,3 +98,23 @@ class GistIndex(PostgresIndex):
if self.fillfactor is not None:
with_params.append('fillfactor = %d' % self.fillfactor)
return with_params
+
+
+class HashIndex(PostgresIndex):
+ suffix = 'hash'
+
+ def __init__(self, *, fillfactor=None, **kwargs):
+ self.fillfactor = fillfactor
+ super().__init__(**kwargs)
+
+ def deconstruct(self):
+ path, args, kwargs = super().deconstruct()
+ if self.fillfactor is not None:
+ kwargs['fillfactor'] = self.fillfactor
+ return path, args, kwargs
+
+ def get_with_params(self):
+ with_params = []
+ if self.fillfactor is not None:
+ with_params.append('fillfactor = %d' % self.fillfactor)
+ return with_params