-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7145 from readthedocs/make-total-results-not-null
Search: Make total_results not null
- Loading branch information
Showing
3 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
readthedocs/search/migrations/0003_migrate_total_results_null_values.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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
18
readthedocs/search/migrations/0004_make_total_results_not_null.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters