-
-
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.
Loading status checks…
Addons: split model and data migrations (#11744)
Showing
3 changed files
with
34 additions
and
26 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
33 changes: 33 additions & 0 deletions
33
readthedocs/projects/migrations/0129_addons_notification_data_migration.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,33 @@ | ||
# Generated by Django 4.2.16 on 2024-11-05 17:33 | ||
|
||
from django.db import migrations | ||
from django.db.models import F | ||
from django_safemigrate import Safe | ||
|
||
|
||
def forward_add_fields(apps, schema_editor): | ||
AddonsConfig = apps.get_model("projects", "AddonsConfig") | ||
AddonsConfig.objects.filter(project__isnull=False).update( | ||
notifications_show_on_latest=F("stable_latest_version_warning_enabled"), | ||
notifications_show_on_non_stable=F("stable_latest_version_warning_enabled"), | ||
notifications_show_on_external=F("external_version_warning_enabled"), | ||
) | ||
|
||
|
||
def reverse_remove_fields(apps, schema_editor): | ||
AddonsConfig = apps.get_model("projects", "AddonsConfig") | ||
AddonsConfig.objects.filter(project__isnull=False).update( | ||
stable_latest_version_warning_enabled=F("notifications_show_on_latest"), | ||
external_version_warning_enabled=F("notifications_show_on_external"), | ||
) | ||
|
||
class Migration(migrations.Migration): | ||
safe = Safe.before_deploy | ||
|
||
dependencies = [ | ||
("projects", "0128_addons_notifications"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(forward_add_fields, reverse_remove_fields), | ||
] |
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