-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prefix FastSpring subscription_id with fs-
- Loading branch information
Showing
2 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
tcms_github_marketplace/migrations/0010_prefix_fastspring_subscription_id.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,36 @@ | ||
# Copyright (c) 2024 Alexander Todorov <[email protected]> | ||
# | ||
# Licensed under GNU Affero General Public License v3 or later (AGPLv3+) | ||
# https://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from django.db import migrations | ||
|
||
|
||
def forwards(apps, schema_editor): # pylint: disable=unused-argument | ||
purchase_model = apps.get_model("tcms_github_marketplace", "Purchase") | ||
for purchase in purchase_model.objects.filter(vendor="fastspring"): | ||
try: | ||
purchase.subscription = f"fs-{purchase.subscription}" | ||
purchase.save() | ||
except: # noqa, pylint: disable=bare-except | ||
pass | ||
|
||
|
||
def backwards(apps, schema_editor): # pylint: disable=unused-argument | ||
purchase_model = apps.get_model("tcms_github_marketplace", "Purchase") | ||
for purchase in purchase_model.objects.filter(vendor="fastspring"): | ||
try: | ||
purchase.subscription = purchase.subscription.lstrip("fs-") | ||
purchase.save() | ||
except: # noqa, pylint: disable=bare-except | ||
pass | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("tcms_github_marketplace", "0009_github_subscription_id"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(forwards, backwards), | ||
] |
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