From acc6bb5e0f67194d68a8e278d2d3b5576c189dd6 Mon Sep 17 00:00:00 2001 From: Santos Gallegos Date: Thu, 25 May 2023 11:15:23 -0500 Subject: [PATCH] PageView: use BigAutoField for primary key (#9670) How to deploy We create page views on 404 and on page views (duh), so while we do the migration this may slow down doc serving (specially on .com where we have this feature enable for everyone), so in order to avoid that we need to disable page views while we do the migration. Luckily we already have a feature flag for that: https://github.com/readthedocs/readthedocs.org/blob/a09bc1a976a93bcc3f987fa0a052901f0065619f/readthedocs/projects/models.py#L1897-L1900 ref https://github.com/readthedocs/readthedocs.org/issues/9492 --- readthedocs/analytics/apps.py | 1 + .../migrations/0006_alter_pageview_id.py | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 readthedocs/analytics/migrations/0006_alter_pageview_id.py diff --git a/readthedocs/analytics/apps.py b/readthedocs/analytics/apps.py index cef2211aa3b..740644a408c 100644 --- a/readthedocs/analytics/apps.py +++ b/readthedocs/analytics/apps.py @@ -7,5 +7,6 @@ class AnalyticsAppConfig(AppConfig): """Analytics app init code.""" + default_auto_field = "django.db.models.BigAutoField" name = 'readthedocs.analytics' verbose_name = 'Analytics' diff --git a/readthedocs/analytics/migrations/0006_alter_pageview_id.py b/readthedocs/analytics/migrations/0006_alter_pageview_id.py new file mode 100644 index 00000000000..e3b8b34ad41 --- /dev/null +++ b/readthedocs/analytics/migrations/0006_alter_pageview_id.py @@ -0,0 +1,20 @@ +# Generated by Django 3.2.15 on 2022-10-18 15:25 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("analytics", "0005_add_unique_constraint"), + ] + + operations = [ + migrations.AlterField( + model_name="pageview", + name="id", + field=models.BigAutoField( + auto_created=True, primary_key=True, serialize=False, verbose_name="ID" + ), + ), + ]