-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[staged-updates] should fix app version history
- Loading branch information
1 parent
14ce977
commit f1ba9d1
Showing
5 changed files
with
106 additions
and
11 deletions.
There are no files selected for viewing
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
57 changes: 57 additions & 0 deletions
57
database/migrations/0119_remove_appversionhistory_app_version_and_more.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,57 @@ | ||
# Generated by Django 4.2.11 on 2024-04-08 05:29 | ||
|
||
from django.db import migrations, models | ||
|
||
# I screwed up the initial implementation of the AppVersionHistory model, but it never generated | ||
# any data so we can just delete it and re-create it. | ||
|
||
def create_initial_appversion_history(apps, schema_editor): | ||
AppVersionHistory = apps.get_model('database', 'AppVersionHistory') | ||
AppVersionHistory.objects.all().delete() | ||
|
||
Participant = apps.get_model('database', 'Participant') | ||
|
||
values = ("pk", "last_version_code", "last_version_name", "last_os_version") | ||
query = Participant.objects.all().values_list(*values) | ||
bulk_creations = [] | ||
for pk, last_version_code, last_version_name, last_os_version in query: | ||
bulk_creations.append(AppVersionHistory( | ||
participant_id=pk, | ||
app_version_code=last_version_code or "missing", | ||
app_version_name=last_version_name or "missing", | ||
os_version=last_os_version or "missing", | ||
)) | ||
AppVersionHistory.objects.bulk_create(bulk_creations) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('database', '0118_filetoprocess_app_version_appversionhistory'), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name='appversionhistory', | ||
name='app_version', | ||
), | ||
migrations.AddField( | ||
model_name='appversionhistory', | ||
name='app_version_code', | ||
field=models.CharField(default='migrated', max_length=16), | ||
preserve_default=False, | ||
), | ||
migrations.AddField( | ||
model_name='appversionhistory', | ||
name='app_version_name', | ||
field=models.CharField(default='migrated', max_length=16), | ||
preserve_default=False, | ||
), | ||
migrations.AddField( | ||
model_name='appversionhistory', | ||
name='os_version', | ||
field=models.CharField(default='migrated', max_length=16), | ||
preserve_default=False, | ||
), | ||
migrations.RunPython(create_initial_appversion_history, reverse_code=migrations.RunPython.noop), | ||
] |
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
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
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