Source code for tcms.testcases.migrations.0024_alter_testcase_extra_link
# Generated by Django 5.2.15 on 2026-06-14 15:29
# pylint: disable=invalid-name, unused-argument
import django.core.validators
from django.db import migrations, models
[docs]
def inspect_extra_links(apps, schema_editor):
TestCase = apps.get_model("testcases", "TestCase")
HistoricalTestCase = apps.get_model("testcases", "HistoricalTestCase")
validator = django.core.validators.URLValidator(
schemes=["http", "https", "ftp", "ftps"]
)
for model in [TestCase, HistoricalTestCase]:
queryset = model.objects.exclude(extra_link__isnull=True).exclude(extra_link="")
for obj in queryset:
try:
validator(obj.extra_link)
except django.core.exceptions.ValidationError:
obj.extra_link = None
obj.save(update_fields=["extra_link"])
[docs]
class Migration(migrations.Migration):
dependencies = [
("testcases", "0023_alter_category_ordering"),
]
operations = [
migrations.RunPython(inspect_extra_links, migrations.RunPython.noop),
migrations.AlterField(
model_name="historicaltestcase",
name="extra_link",
field=models.URLField(
blank=True,
default=None,
max_length=1024,
null=True,
validators=[
django.core.validators.URLValidator(
schemes=["http", "https", "ftp", "ftps"]
)
],
),
),
migrations.AlterField(
model_name="testcase",
name="extra_link",
field=models.URLField(
blank=True,
default=None,
max_length=1024,
null=True,
validators=[
django.core.validators.URLValidator(
schemes=["http", "https", "ftp", "ftps"]
)
],
),
),
]