Skip to content

Commit

Permalink
ImportedFile: use BigAutoField for primary key
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 committed Oct 18, 2022
1 parent a09bc1a commit d6f9fa2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions readthedocs/projects/migrations/0094_alter_importedfile_id.py
Original file line number Diff line number Diff line change
@@ -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),
),
]
1 change: 1 addition & 0 deletions readthedocs/projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down

0 comments on commit d6f9fa2

Please sign in to comment.