wip: add index of unaccented upper value of role.name
gitea/authentic/pipeline/head There was a failure building this commit Details

This commit is contained in:
Benjamin Dauvergne 2024-03-28 17:25:21 +01:00
parent 7e04fa9374
commit 48ce80f38a
2 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,25 @@
# Generated by Django 3.2.23 on 2024-03-28 16:23
import django.db.models.expressions
import django.db.models.functions.text
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('a2_rbac', '0039_set_user_view_permissions_by_ou'),
]
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'
)
),
name='name_idx',
),
),
]

View File

@ -27,6 +27,7 @@ from django.contrib.postgres.fields import ArrayField
from django.core.exceptions import ValidationError
from django.core.validators import MinValueValidator
from django.db import models
from django.db.models.functions import Upper
from django.db.models.query import Prefetch, Q
from django.urls import reverse
from django.utils.text import slugify
@ -614,6 +615,9 @@ class Role(AbstractBase):
condition=models.Q(service__isnull=True, ou__isnull=True, admin_scope_ct__isnull=True),
),
]
indexes = [
models.Index(Upper(models.Func(models.F('name'), name='immutable_unaccent')), name='name_idx')
]
def natural_key(self):
return [