models: Migrate ids of UserActivity and UserActivityInterval to bigint.

These models have no external references, and are among the larger
tables.  Migrate them to bigints, starting with `useractivityinterval`
which is less likely to be being touched.
This commit is contained in:
Alex Vandiver 2024-05-29 20:05:32 +00:00 committed by Tim Abbott
parent 4f4725f810
commit 37803406e5
2 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,26 @@
from django.db import migrations, models
class Migration(migrations.Migration):
atomic = False
dependencies = [
("zerver", "0529_fts_bigint_id"),
]
operations = [
migrations.AlterField(
model_name="useractivityinterval",
name="id",
field=models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
migrations.AlterField(
model_name="useractivity",
name="id",
field=models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
]

View File

@ -19,6 +19,9 @@ class UserActivity(models.Model):
and database migration purposes.
"""
id = models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
)
user_profile = models.ForeignKey(UserProfile, on_delete=CASCADE)
client = models.ForeignKey(Client, on_delete=CASCADE)
query = models.CharField(max_length=50, db_index=True)
@ -33,6 +36,9 @@ class UserActivity(models.Model):
class UserActivityInterval(models.Model):
MIN_INTERVAL_LENGTH = timedelta(minutes=15)
id = models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
)
user_profile = models.ForeignKey(UserProfile, on_delete=CASCADE)
start = models.DateTimeField("start time", db_index=True)
end = models.DateTimeField("end time", db_index=True)