Skip to content

Commit

Permalink
OpenConceptLab/ocl_issues#1082 Add GIN, GIST, TRGM extensions and con…
Browse files Browse the repository at this point in the history
…cepts uri index
  • Loading branch information
rkorytkowski committed Nov 9, 2021
1 parent 43b9d0e commit 904904a
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 0 deletions.
13 changes: 13 additions & 0 deletions core/common/migrations/0001_create_ext_btree_gist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Generated by Django 3.2.8 on 2021-11-09 09:56
from django.contrib.postgres.operations import BtreeGistExtension
from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
]

operations = [
BtreeGistExtension()
]
14 changes: 14 additions & 0 deletions core/common/migrations/0002_create_ext_trigram.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Django 3.2.8 on 2021-11-09 09:59
from django.contrib.postgres.operations import TrigramExtension
from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('common', '0001_create_ext_btree_gist'),
]

operations = [
TrigramExtension()
]
14 changes: 14 additions & 0 deletions core/common/migrations/0003_create_ext_btree_gin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Django 3.2.8 on 2021-11-09 10:03
from django.contrib.postgres.operations import BtreeGinExtension
from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('common', '0002_create_ext_trigram'),
]

operations = [
BtreeGinExtension()
]
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.8 on 2021-11-09 10:14

import django.contrib.postgres.indexes
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('concepts', '0023_concept_concepts_public_conditional'),
]

operations = [
migrations.AddIndex(
model_name='concept',
index=django.contrib.postgres.indexes.GinIndex(condition=models.Q(('is_latest_version', True)), fields=['uri', 'id'], name='concepts_uri_trgm_id_gin_idx', opclasses=['gin_trgm_ops', 'int8_ops']),
),
]
2 changes: 2 additions & 0 deletions core/concepts/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.conf import settings
from django.contrib.postgres.indexes import GinIndex
from django.core.exceptions import ValidationError
from django.core.validators import RegexValidator
from django.db import models, IntegrityError, transaction, connection
Expand Down Expand Up @@ -149,6 +150,7 @@ class Meta:
models.Index(name='concepts_public_conditional', fields=['public_access'],
condition=(Q(is_active=True) & Q(retired=False) & Q(is_latest_version=True) &
~Q(public_access='None'))),
GinIndex(name='concepts_uri_trgm_id_gin_idx', fields=['uri', 'id'], opclasses=['gin_trgm_ops', 'int8_ops'], condition=Q(is_latest_version=True))
] + VersionedModel.Meta.indexes

external_id = models.TextField(null=True, blank=True)
Expand Down

0 comments on commit 904904a

Please sign in to comment.