RemotePushDevice: Migrate token_kind from IntegerChoices to TextChoices.

Improves code readability by using string values ("apns", "fcm")
instead of integers (1, 2).
This commit is contained in:
Prakhar Pratyush
2025-07-09 18:42:38 +05:30
committed by Tim Abbott
parent 7a26c41c42
commit e10d413476
2 changed files with 21 additions and 4 deletions

View File

@@ -0,0 +1,17 @@
# Generated by Django 5.2.3 on 2025-07-09 13:11
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("zilencer", "0065_remotepushdevice"),
]
operations = [
migrations.AlterField(
model_name="remotepushdevice",
name="token_kind",
field=models.CharField(choices=[("apns", "APNs"), ("fcm", "FCM")], max_length=4),
),
]

View File

@@ -618,11 +618,11 @@ class RemotePushDevice(models.Model):
# that they're at most the maximum FCM / APNs payload size of 4096 bytes.
token = models.CharField(max_length=4096)
class TokenKind(models.IntegerChoices):
APNS = 1, "APNs"
FCM = 2, "FCM"
class TokenKind(models.TextChoices):
APNS = "apns", "APNs"
FCM = "fcm", "FCM"
token_kind = models.PositiveSmallIntegerField(choices=TokenKind.choices)
token_kind = models.CharField(max_length=4, choices=TokenKind.choices)
# 64-bit random integer ID generated by the client; will only be
# guaranteed to be unique within the client's own table of accounts.