-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#660: add migration to remove trailing/leading whitespace from Seed u…
…rls, ensure they get stripped in form
- Loading branch information
Showing
2 changed files
with
33 additions
and
0 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
26 changes: 26 additions & 0 deletions
26
Seeder/source/migrations/0007_strip_seed_urls_20240718_0951.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,26 @@ | ||
# Generated by Django 2.2.28 on 2024-07-18 09:51 | ||
|
||
from django.db import migrations | ||
|
||
def strip_old_seed_urls(apps, schema_editor): | ||
""" Strip spaces from Seed URLs with leading/trailing whitespace """ | ||
Seed = apps.get_model("source", "Seed") | ||
for seed in Seed.objects.filter(url__contains=" "): | ||
seed.url = seed.url.strip() | ||
seed.save() | ||
|
||
def reverse_strip_old_seed_urls(apps, schema_editor): | ||
""" I'm not adding spaces back to Seed urls... """ | ||
pass | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('source', '0006_auto_20220826_1306'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(strip_old_seed_urls, | ||
reverse_code=reverse_strip_old_seed_urls), | ||
] |