core: add indexes on ExpiringModel (#12658)
This commit is contained in:
committed by
GitHub
parent
c0a370bb2b
commit
3098313981
@ -0,0 +1,45 @@
|
|||||||
|
# Generated by Django 5.0.10 on 2025-01-13 18:05
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("authentik_core", "0041_applicationentitlement"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="authenticatedsession",
|
||||||
|
index=models.Index(fields=["expires"], name="authentik_c_expires_08251d_idx"),
|
||||||
|
),
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="authenticatedsession",
|
||||||
|
index=models.Index(fields=["expiring"], name="authentik_c_expirin_9cd839_idx"),
|
||||||
|
),
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="authenticatedsession",
|
||||||
|
index=models.Index(
|
||||||
|
fields=["expiring", "expires"], name="authentik_c_expirin_195a84_idx"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="authenticatedsession",
|
||||||
|
index=models.Index(fields=["session_key"], name="authentik_c_session_d0f005_idx"),
|
||||||
|
),
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="token",
|
||||||
|
index=models.Index(fields=["expires"], name="authentik_c_expires_a62b4b_idx"),
|
||||||
|
),
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="token",
|
||||||
|
index=models.Index(fields=["expiring"], name="authentik_c_expirin_a1b838_idx"),
|
||||||
|
),
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="token",
|
||||||
|
index=models.Index(
|
||||||
|
fields=["expiring", "expires"], name="authentik_c_expirin_ba04d9_idx"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
@ -846,6 +846,11 @@ class ExpiringModel(models.Model):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
abstract = True
|
abstract = True
|
||||||
|
indexes = [
|
||||||
|
models.Index(fields=["expires"]),
|
||||||
|
models.Index(fields=["expiring"]),
|
||||||
|
models.Index(fields=["expiring", "expires"]),
|
||||||
|
]
|
||||||
|
|
||||||
def expire_action(self, *args, **kwargs):
|
def expire_action(self, *args, **kwargs):
|
||||||
"""Handler which is called when this object is expired. By
|
"""Handler which is called when this object is expired. By
|
||||||
@ -901,7 +906,7 @@ class Token(SerializerModel, ManagedModel, ExpiringModel):
|
|||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _("Token")
|
verbose_name = _("Token")
|
||||||
verbose_name_plural = _("Tokens")
|
verbose_name_plural = _("Tokens")
|
||||||
indexes = [
|
indexes = ExpiringModel.Meta.indexes + [
|
||||||
models.Index(fields=["identifier"]),
|
models.Index(fields=["identifier"]),
|
||||||
models.Index(fields=["key"]),
|
models.Index(fields=["key"]),
|
||||||
]
|
]
|
||||||
@ -1001,6 +1006,9 @@ class AuthenticatedSession(ExpiringModel):
|
|||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _("Authenticated Session")
|
verbose_name = _("Authenticated Session")
|
||||||
verbose_name_plural = _("Authenticated Sessions")
|
verbose_name_plural = _("Authenticated Sessions")
|
||||||
|
indexes = ExpiringModel.Meta.indexes + [
|
||||||
|
models.Index(fields=["session_key"]),
|
||||||
|
]
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return f"Authenticated Session {self.session_key[:10]}"
|
return f"Authenticated Session {self.session_key[:10]}"
|
||||||
|
|||||||
@ -0,0 +1,27 @@
|
|||||||
|
# Generated by Django 5.0.10 on 2025-01-13 18:05
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("authentik_enterprise", "0003_remove_licenseusage_within_limits_and_more"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="licenseusage",
|
||||||
|
index=models.Index(fields=["expires"], name="authentik_e_expires_3f2956_idx"),
|
||||||
|
),
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="licenseusage",
|
||||||
|
index=models.Index(fields=["expiring"], name="authentik_e_expirin_11d3d7_idx"),
|
||||||
|
),
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="licenseusage",
|
||||||
|
index=models.Index(
|
||||||
|
fields=["expiring", "expires"], name="authentik_e_expirin_4d558f_idx"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
@ -93,3 +93,4 @@ class LicenseUsage(ExpiringModel):
|
|||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _("License Usage")
|
verbose_name = _("License Usage")
|
||||||
verbose_name_plural = _("License Usage Records")
|
verbose_name_plural = _("License Usage Records")
|
||||||
|
indexes = ExpiringModel.Meta.indexes
|
||||||
|
|||||||
@ -0,0 +1,28 @@
|
|||||||
|
# Generated by Django 5.0.10 on 2025-01-13 18:05
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("authentik_core", "0042_authenticatedsession_authentik_c_expires_08251d_idx_and_more"),
|
||||||
|
("authentik_providers_rac", "0005_alter_racpropertymapping_options"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="connectiontoken",
|
||||||
|
index=models.Index(fields=["expires"], name="authentik_p_expires_91f148_idx"),
|
||||||
|
),
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="connectiontoken",
|
||||||
|
index=models.Index(fields=["expiring"], name="authentik_p_expirin_59a5a7_idx"),
|
||||||
|
),
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="connectiontoken",
|
||||||
|
index=models.Index(
|
||||||
|
fields=["expiring", "expires"], name="authentik_p_expirin_aed3ca_idx"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
@ -211,3 +211,4 @@ class ConnectionToken(ExpiringModel):
|
|||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _("RAC Connection token")
|
verbose_name = _("RAC Connection token")
|
||||||
verbose_name_plural = _("RAC Connection tokens")
|
verbose_name_plural = _("RAC Connection tokens")
|
||||||
|
indexes = ExpiringModel.Meta.indexes
|
||||||
|
|||||||
@ -0,0 +1,41 @@
|
|||||||
|
# Generated by Django 5.0.10 on 2025-01-13 18:05
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("authentik_events", "0007_event_authentik_e_action_9a9dd9_idx_and_more"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="event",
|
||||||
|
index=models.Index(fields=["expires"], name="authentik_e_expires_8c73a8_idx"),
|
||||||
|
),
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="event",
|
||||||
|
index=models.Index(fields=["expiring"], name="authentik_e_expirin_b5cb5e_idx"),
|
||||||
|
),
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="event",
|
||||||
|
index=models.Index(
|
||||||
|
fields=["expiring", "expires"], name="authentik_e_expirin_e37180_idx"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="systemtask",
|
||||||
|
index=models.Index(fields=["expires"], name="authentik_e_expires_4d3985_idx"),
|
||||||
|
),
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="systemtask",
|
||||||
|
index=models.Index(fields=["expiring"], name="authentik_e_expirin_81d649_idx"),
|
||||||
|
),
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="systemtask",
|
||||||
|
index=models.Index(
|
||||||
|
fields=["expiring", "expires"], name="authentik_e_expirin_eb3598_idx"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
@ -306,7 +306,7 @@ class Event(SerializerModel, ExpiringModel):
|
|||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _("Event")
|
verbose_name = _("Event")
|
||||||
verbose_name_plural = _("Events")
|
verbose_name_plural = _("Events")
|
||||||
indexes = [
|
indexes = ExpiringModel.Meta.indexes + [
|
||||||
models.Index(fields=["action"]),
|
models.Index(fields=["action"]),
|
||||||
models.Index(fields=["user"]),
|
models.Index(fields=["user"]),
|
||||||
models.Index(fields=["app"]),
|
models.Index(fields=["app"]),
|
||||||
@ -694,3 +694,4 @@ class SystemTask(SerializerModel, ExpiringModel):
|
|||||||
permissions = [("run_task", _("Run task"))]
|
permissions = [("run_task", _("Run task"))]
|
||||||
verbose_name = _("System Task")
|
verbose_name = _("System Task")
|
||||||
verbose_name_plural = _("System Tasks")
|
verbose_name_plural = _("System Tasks")
|
||||||
|
indexes = ExpiringModel.Meta.indexes
|
||||||
|
|||||||
@ -0,0 +1,30 @@
|
|||||||
|
# Generated by Django 5.0.10 on 2025-01-13 18:05
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
(
|
||||||
|
"authentik_policies_reputation",
|
||||||
|
"0007_reputation_authentik_p_identif_9434d7_idx_and_more",
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="reputation",
|
||||||
|
index=models.Index(fields=["expires"], name="authentik_p_expires_da493f_idx"),
|
||||||
|
),
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="reputation",
|
||||||
|
index=models.Index(fields=["expiring"], name="authentik_p_expirin_2ab34f_idx"),
|
||||||
|
),
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="reputation",
|
||||||
|
index=models.Index(
|
||||||
|
fields=["expiring", "expires"], name="authentik_p_expirin_2a8ec7_idx"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
@ -96,7 +96,7 @@ class Reputation(ExpiringModel, SerializerModel):
|
|||||||
verbose_name = _("Reputation Score")
|
verbose_name = _("Reputation Score")
|
||||||
verbose_name_plural = _("Reputation Scores")
|
verbose_name_plural = _("Reputation Scores")
|
||||||
unique_together = ("identifier", "ip")
|
unique_together = ("identifier", "ip")
|
||||||
indexes = [
|
indexes = ExpiringModel.Meta.indexes + [
|
||||||
models.Index(fields=["identifier"]),
|
models.Index(fields=["identifier"]),
|
||||||
models.Index(fields=["ip"]),
|
models.Index(fields=["ip"]),
|
||||||
models.Index(fields=["ip", "identifier"]),
|
models.Index(fields=["ip", "identifier"]),
|
||||||
|
|||||||
@ -0,0 +1,72 @@
|
|||||||
|
# Generated by Django 5.0.10 on 2025-01-13 18:05
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("authentik_core", "0042_authenticatedsession_authentik_c_expires_08251d_idx_and_more"),
|
||||||
|
("authentik_providers_oauth2", "0026_alter_accesstoken_session_and_more"),
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="accesstoken",
|
||||||
|
index=models.Index(fields=["expires"], name="authentik_p_expires_9f24a5_idx"),
|
||||||
|
),
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="accesstoken",
|
||||||
|
index=models.Index(fields=["expiring"], name="authentik_p_expirin_2d9205_idx"),
|
||||||
|
),
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="accesstoken",
|
||||||
|
index=models.Index(
|
||||||
|
fields=["expiring", "expires"], name="authentik_p_expirin_c74005_idx"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="authorizationcode",
|
||||||
|
index=models.Index(fields=["expires"], name="authentik_p_expires_f594b2_idx"),
|
||||||
|
),
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="authorizationcode",
|
||||||
|
index=models.Index(fields=["expiring"], name="authentik_p_expirin_6a5e2c_idx"),
|
||||||
|
),
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="authorizationcode",
|
||||||
|
index=models.Index(
|
||||||
|
fields=["expiring", "expires"], name="authentik_p_expirin_c0f353_idx"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="devicetoken",
|
||||||
|
index=models.Index(fields=["expires"], name="authentik_p_expires_961437_idx"),
|
||||||
|
),
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="devicetoken",
|
||||||
|
index=models.Index(fields=["expiring"], name="authentik_p_expirin_4fd278_idx"),
|
||||||
|
),
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="devicetoken",
|
||||||
|
index=models.Index(
|
||||||
|
fields=["expiring", "expires"], name="authentik_p_expirin_cd6b1c_idx"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="refreshtoken",
|
||||||
|
index=models.Index(fields=["expires"], name="authentik_p_expires_c479a7_idx"),
|
||||||
|
),
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="refreshtoken",
|
||||||
|
index=models.Index(fields=["expiring"], name="authentik_p_expirin_d4d17f_idx"),
|
||||||
|
),
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="refreshtoken",
|
||||||
|
index=models.Index(
|
||||||
|
fields=["expiring", "expires"], name="authentik_p_expirin_acb4a5_idx"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
@ -425,6 +425,7 @@ class AuthorizationCode(SerializerModel, ExpiringModel, BaseGrantModel):
|
|||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _("Authorization Code")
|
verbose_name = _("Authorization Code")
|
||||||
verbose_name_plural = _("Authorization Codes")
|
verbose_name_plural = _("Authorization Codes")
|
||||||
|
indexes = ExpiringModel.Meta.indexes
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"Authorization code for {self.provider_id} for user {self.user_id}"
|
return f"Authorization code for {self.provider_id} for user {self.user_id}"
|
||||||
@ -453,7 +454,7 @@ class AccessToken(SerializerModel, ExpiringModel, BaseGrantModel):
|
|||||||
_id_token = models.TextField()
|
_id_token = models.TextField()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
indexes = [
|
indexes = ExpiringModel.Meta.indexes + [
|
||||||
HashIndex(fields=["token"]),
|
HashIndex(fields=["token"]),
|
||||||
]
|
]
|
||||||
verbose_name = _("OAuth2 Access Token")
|
verbose_name = _("OAuth2 Access Token")
|
||||||
@ -504,7 +505,7 @@ class RefreshToken(SerializerModel, ExpiringModel, BaseGrantModel):
|
|||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
indexes = [
|
indexes = ExpiringModel.Meta.indexes + [
|
||||||
HashIndex(fields=["token"]),
|
HashIndex(fields=["token"]),
|
||||||
]
|
]
|
||||||
verbose_name = _("OAuth2 Refresh Token")
|
verbose_name = _("OAuth2 Refresh Token")
|
||||||
@ -556,6 +557,7 @@ class DeviceToken(ExpiringModel):
|
|||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _("Device Token")
|
verbose_name = _("Device Token")
|
||||||
verbose_name_plural = _("Device Tokens")
|
verbose_name_plural = _("Device Tokens")
|
||||||
|
indexes = ExpiringModel.Meta.indexes
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"Device Token for {self.provider_id}"
|
return f"Device Token for {self.provider_id}"
|
||||||
|
|||||||
@ -0,0 +1,30 @@
|
|||||||
|
# Generated by Django 5.0.10 on 2025-01-13 18:05
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("authentik_core", "0042_authenticatedsession_authentik_c_expires_08251d_idx_and_more"),
|
||||||
|
("authentik_stages_consent", "0006_alter_userconsent_expires"),
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="userconsent",
|
||||||
|
index=models.Index(fields=["expires"], name="authentik_s_expires_0e99e8_idx"),
|
||||||
|
),
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="userconsent",
|
||||||
|
index=models.Index(fields=["expiring"], name="authentik_s_expirin_8f51e5_idx"),
|
||||||
|
),
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="userconsent",
|
||||||
|
index=models.Index(
|
||||||
|
fields=["expiring", "expires"], name="authentik_s_expirin_e50090_idx"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
@ -71,3 +71,4 @@ class UserConsent(SerializerModel, ExpiringModel):
|
|||||||
unique_together = (("user", "application", "permissions"),)
|
unique_together = (("user", "application", "permissions"),)
|
||||||
verbose_name = _("User Consent")
|
verbose_name = _("User Consent")
|
||||||
verbose_name_plural = _("User Consents")
|
verbose_name_plural = _("User Consents")
|
||||||
|
indexes = ExpiringModel.Meta.indexes
|
||||||
|
|||||||
@ -0,0 +1,30 @@
|
|||||||
|
# Generated by Django 5.0.10 on 2025-01-13 18:05
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("authentik_flows", "0027_auto_20231028_1424"),
|
||||||
|
("authentik_stages_invitation", "0008_alter_invitation_expires"),
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="invitation",
|
||||||
|
index=models.Index(fields=["expires"], name="authentik_s_expires_96f4b8_idx"),
|
||||||
|
),
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="invitation",
|
||||||
|
index=models.Index(fields=["expiring"], name="authentik_s_expirin_4f8f35_idx"),
|
||||||
|
),
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="invitation",
|
||||||
|
index=models.Index(
|
||||||
|
fields=["expiring", "expires"], name="authentik_s_expirin_4f8096_idx"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
@ -84,3 +84,4 @@ class Invitation(SerializerModel, ExpiringModel):
|
|||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _("Invitation")
|
verbose_name = _("Invitation")
|
||||||
verbose_name_plural = _("Invitations")
|
verbose_name_plural = _("Invitations")
|
||||||
|
indexes = ExpiringModel.Meta.indexes
|
||||||
|
|||||||
Reference in New Issue
Block a user