From d6f9fa2b6872437fb6d043299675c970a85f910b Mon Sep 17 00:00:00 2001 From: Santos Gallegos Date: Tue, 18 Oct 2022 09:45:15 -0500 Subject: [PATCH] ImportedFile: use BigAutoField for primary key We could disable search indexing while we do the migration, but I don't think that should be required, we have 11M records, but to migrate the SphinxDomain model it took 15 min, and we had ~56M. ```python In [7]: ImportedFile.objects.count() Out[7]: 11527437 ``` So some 3 min of not being able to index new versions doesn't seem bad... There are two things that could happen: - The query times out and we don't index that version. - The query waits till the migration is done, nothing gets lost. But if we disable search indexing we definitely won't index new versions. We don't use those models outside search indexing, so doc serving and such shouldn't be affected. ref https://github.com/readthedocs/readthedocs.org/issues/9492 --- .../migrations/0094_alter_importedfile_id.py | 18 ++++++++++++++++++ readthedocs/projects/models.py | 1 + 2 files changed, 19 insertions(+) create mode 100644 readthedocs/projects/migrations/0094_alter_importedfile_id.py diff --git a/readthedocs/projects/migrations/0094_alter_importedfile_id.py b/readthedocs/projects/migrations/0094_alter_importedfile_id.py new file mode 100644 index 00000000000..f2bdb89dc43 --- /dev/null +++ b/readthedocs/projects/migrations/0094_alter_importedfile_id.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.15 on 2022-10-18 14:21 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("projects", "0093_migrate_null_fields"), + ] + + operations = [ + migrations.AlterField( + model_name="importedfile", + name="id", + field=models.BigAutoField(primary_key=True, serialize=False), + ), + ] diff --git a/readthedocs/projects/models.py b/readthedocs/projects/models.py index 24c10161d2d..4e3cd3a2f80 100644 --- a/readthedocs/projects/models.py +++ b/readthedocs/projects/models.py @@ -1345,6 +1345,7 @@ class ImportedFile(models.Model): things like CDN invalidation. """ + id = models.BigAutoField(primary_key=True) project = models.ForeignKey( Project, verbose_name=_('Project'),