Compare commits

..

1 Commits

Author SHA1 Message Date
Benjamin Dauvergne 12fc4ef9f0 wip: add index of unaccented upper value of role.name
gitea/authentic/pipeline/head This commit looks good Details
2024-03-28 17:50:56 +01:00
2 changed files with 18 additions and 8 deletions

View File

@ -1,8 +1,9 @@
# Generated by Django 3.2.23 on 2024-03-28 16:23
# Generated by Django 3.2.23 on 2024-03-28 16:50
import django.contrib.postgres.indexes
import django.db.models.expressions
import django.db.models.functions.text
from django.db import migrations, models
from django.db import migrations
class Migration(migrations.Migration):
@ -13,11 +14,14 @@ class Migration(migrations.Migration):
operations = [
migrations.AddIndex(
model_name='role',
index=models.Index(
django.db.models.functions.text.Upper(
django.db.models.expressions.Func(
django.db.models.expressions.F('name'), name='immutable_unaccent'
)
index=django.contrib.postgres.indexes.GinIndex(
django.contrib.postgres.indexes.OpClass(
django.db.models.functions.text.Upper(
django.db.models.expressions.Func(
django.db.models.expressions.F('name'), function='immutable_unaccent'
)
),
'public.gin_trgm_ops',
),
name='name_idx',
),

View File

@ -23,6 +23,7 @@ from django.conf import settings
from django.contrib.auth import get_user_model
from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation
from django.contrib.contenttypes.models import ContentType
from django.contrib.postgres import indexes as postgresql_indexes
from django.contrib.postgres.fields import ArrayField
from django.core.exceptions import ValidationError
from django.core.validators import MinValueValidator
@ -616,7 +617,12 @@ class Role(AbstractBase):
),
]
indexes = [
models.Index(Upper(models.Func(models.F('name'), name='immutable_unaccent')), name='name_idx')
postgresql_indexes.GinIndex(
postgresql_indexes.OpClass(
Upper(models.Func(models.F('name'), function='immutable_unaccent')), 'public.gin_trgm_ops'
),
name='name_idx',
),
]
def natural_key(self):