diff --git a/bookmarks/migrations/0051_fix_normalized_url.py b/bookmarks/migrations/0051_fix_normalized_url.py new file mode 100644 index 0000000..adc6e9d --- /dev/null +++ b/bookmarks/migrations/0051_fix_normalized_url.py @@ -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, + ), + ] diff --git a/scripts/run-postgres.sh b/scripts/run-postgres.sh index c6ac16c..43c4ab7 100755 --- a/scripts/run-postgres.sh +++ b/scripts/run-postgres.sh @@ -9,6 +9,7 @@ docker run -d \ -e POSTGRES_USER=linkding \ -e POSTGRES_PASSWORD=linkding \ -p 5432:5432 \ + -v $(pwd)/tmp/postgres-data:/var/lib/postgresql/data \ --name linkding-postgres-test \ postgres