Skip to content

Commit

Permalink
Merge pull request #7145 from readthedocs/make-total-results-not-null
Browse files Browse the repository at this point in the history
Search: Make total_results not null
  • Loading branch information
stsewd committed Jun 2, 2020
2 parents 87a5145 + a7f5b8b commit 3501c3f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
@@ -0,0 +1,20 @@
# Generated by Django 2.2.12 on 2020-06-01 18:00

from django.db import migrations


def forwards_func(apps, schema_editor):
"""Make all total_results fields not none."""
SearchQuery = apps.get_model('search', 'SearchQuery')
SearchQuery.objects.filter(total_results=None).update(total_results=0)


class Migration(migrations.Migration):

dependencies = [
('search', '0002_add_total_results_field'),
]

operations = [
migrations.RunPython(forwards_func),
]
18 changes: 18 additions & 0 deletions readthedocs/search/migrations/0004_make_total_results_not_null.py
@@ -0,0 +1,18 @@
# Generated by Django 2.2.12 on 2020-06-01 18:00

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('search', '0003_migrate_total_results_null_values'),
]

operations = [
migrations.AlterField(
model_name='searchquery',
name='total_results',
field=models.IntegerField(default=0, verbose_name='Total results'),
),
]
2 changes: 0 additions & 2 deletions readthedocs/search/models.py
Expand Up @@ -36,8 +36,6 @@ class SearchQuery(TimeStampedModel):
total_results = models.IntegerField(
_('Total results'),
default=0,
# TODO: to avoid downtime, remove later.
null=True,
)
objects = RelatedProjectQuerySet.as_manager()

Expand Down

0 comments on commit 3501c3f

Please sign in to comment.