fix: address review feedback — URLField→CharField, safe reverse migration
- Change SocialMediaLink.url and NavigationMenuItem.link_url from URLField to CharField(max_length=500) to support internal paths like /feed/ that fail URLField validation - Replace destructive reverse_seed (deleted ALL rows) with RunPython.noop to prevent data loss on rollback Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -93,13 +93,6 @@ def seed_navigation_data(apps, schema_editor):
|
||||
)
|
||||
|
||||
|
||||
def reverse_seed(apps, schema_editor):
|
||||
NavigationMenuItem = apps.get_model("core", "NavigationMenuItem")
|
||||
SocialMediaLink = apps.get_model("core", "SocialMediaLink")
|
||||
NavigationMenuItem.objects.all().delete()
|
||||
SocialMediaLink.objects.all().delete()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
@@ -108,5 +101,5 @@ class Migration(migrations.Migration):
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(seed_navigation_data, reverse_seed),
|
||||
migrations.RunPython(seed_navigation_data, migrations.RunPython.noop),
|
||||
]
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
# Generated by Django 5.2.11 on 2026-03-02 19:35
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('core', '0003_seed_navigation_data'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='navigationmenuitem',
|
||||
name='link_url',
|
||||
field=models.CharField(blank=True, default='', help_text='URL or path (used only when no page is selected).', max_length=500),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='socialmedialink',
|
||||
name='url',
|
||||
field=models.CharField(help_text='URL or path (e.g. https://twitter.com/… or /feed/).', max_length=500),
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user