feat: add rate limit field to APIToken model and update workspace user preferences

This commit is contained in:
pablohashescobar
2025-11-27 18:05:34 +05:30
parent 73c317f283
commit c8fb6ec137
2 changed files with 30 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
# Generated by Django 4.2.25 on 2025-11-27 12:34
from django.db import migrations, models
def migrate_workspace_user_preferences_is_pinned(apps, schema_editor):
"""
Set DRAFTS, YOUR_WORK, STICKIES default to pinned
"""
apps.get_model("db", "WorkspaceUserPreference").objects.filter(key__in=["drafts", "your_work", "stickies"]).update(is_pinned=True)
class Migration(migrations.Migration):
dependencies = [
('db', '0111_notification_notif_receiver_status_idx_and_more'),
]
operations = [
migrations.AddField(
model_name='apitoken',
name='rate_limit',
field=models.CharField(default='60/min', max_length=255),
),
migrations.RunPython(
migrate_workspace_user_preferences_is_pinned,
reverse_code=migrations.RunPython.noop
),
]

View File

@@ -32,6 +32,7 @@ class APIToken(BaseModel):
workspace = models.ForeignKey("db.Workspace", related_name="api_tokens", on_delete=models.CASCADE, null=True)
expired_at = models.DateTimeField(blank=True, null=True)
is_service = models.BooleanField(default=False)
rate_limit = models.CharField(max_length=255, default="60/min")
class Meta:
verbose_name = "API Token"