Attempt to fix botched normalized URL migration from 1.43.0 (#1205)

This commit is contained in:
Sascha Ißbrücker
2025-10-11 11:12:27 +02:00
committed by GitHub
parent 95529eccd4
commit eb99ece360
2 changed files with 35 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
# 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,
),
]

View File

@@ -9,6 +9,7 @@ docker run -d \
-e POSTGRES_USER=linkding \ -e POSTGRES_USER=linkding \
-e POSTGRES_PASSWORD=linkding \ -e POSTGRES_PASSWORD=linkding \
-p 5432:5432 \ -p 5432:5432 \
-v $(pwd)/tmp/postgres-data:/var/lib/postgresql/data \
--name linkding-postgres-test \ --name linkding-postgres-test \
postgres postgres