mirror of
https://github.com/sissbruecker/linkding.git
synced 2025-11-17 03:24:05 +01:00
35 lines
891 B
Python
35 lines
891 B
Python
# Generated by Django 5.2.5 on 2025-10-11 08:46
|
|
|
|
from django.db import migrations
|
|
from bookmarks.utils import normalize_url
|
|
|
|
|
|
def fix_url_normalized(apps, schema_editor):
|
|
Bookmark = apps.get_model("bookmarks", "Bookmark")
|
|
|
|
batch_size = 200
|
|
qs = Bookmark.objects.filter(url_normalized="").all()
|
|
for start in range(0, qs.count(), batch_size):
|
|
batch = list(qs[start : start + batch_size])
|
|
for bookmark in batch:
|
|
bookmark.url_normalized = normalize_url(bookmark.url)
|
|
Bookmark.objects.bulk_update(batch, ["url_normalized"])
|
|
|
|
|
|
def reverse_fix_url_normalized(apps, schema_editor):
|
|
pass
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
("bookmarks", "0050_new_search_toast"),
|
|
]
|
|
|
|
operations = [
|
|
migrations.RunPython(
|
|
fix_url_normalized,
|
|
reverse_fix_url_normalized,
|
|
),
|
|
]
|