Files
zulip/zerver/migrations/0451_add_userprofile_api_key_index.py
Alex Vandiver c978bfaa32 models: Add a unique index on UserProfile.api_key.
This prevents `get_user_profile_by_api_key` from doing a sequential
scan.

Doing this requires moving the generation of initial api_key values
into the column definition, so that even bare calls to
`UserProfile.objects.create` (e.g. from tests) call appropriately
generate a random initial value.
2023-05-19 11:11:04 -07:00

21 lines
490 B
Python

# Generated by Django 4.2.1 on 2023-05-18 15:20
from django.db import migrations, models
from zerver.lib.utils import generate_api_key
class Migration(migrations.Migration):
dependencies = [
("zerver", "0450_backfill_subscription_auditlogs"),
]
operations = [
migrations.AlterField(
model_name="userprofile",
name="api_key",
field=models.CharField(default=generate_api_key, max_length=32, unique=True),
),
]