Skip to content

Commit

Permalink
ImportedFile: use BigAutoField for primary key (#9669)
Browse files Browse the repository at this point in the history
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 #9492
  • Loading branch information
stsewd authored Jan 30, 2025
1 parent 7a3a718 commit f041c62
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions readthedocs/projects/migrations/0144_alter_importedfile_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from django.db import migrations, models
from django_safemigrate import Safe


class Migration(migrations.Migration):

safe = Safe.after_deploy

dependencies = [
("projects", "0143_addons_flyout_position"),
]

operations = [
migrations.AlterField(
model_name="importedfile",
name="id",
field=models.BigAutoField(primary_key=True, serialize=False),
),
]
1 change: 1 addition & 0 deletions readthedocs/projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1488,6 +1488,7 @@ class ImportedFile(models.Model):
things like CDN invalidation.
"""

id = models.BigAutoField(primary_key=True)
project = models.ForeignKey(
Project,
verbose_name=_("Project"),
Expand Down

0 comments on commit f041c62

Please sign in to comment.