Page MenuHomeSoftware Heritage

0005_remove_duplicated_authorized_origins.py
No OneTemporary

0005_remove_duplicated_authorized_origins.py

# Copyright (C) 2019 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU Affero General Public License version 3, or any later version
# See top-level LICENSE file for more information
from __future__ import unicode_literals
from django.db import migrations
from swh.web.common.models import SaveAuthorizedOrigin
def _remove_duplicated_urls_in_authorized_list(apps, schema_editor):
sao = SaveAuthorizedOrigin.objects
for url in sao.values_list("url", flat=True).distinct():
sao.filter(pk__in=sao.filter(url=url).values_list("id", flat=True)[1:]).delete()
class Migration(migrations.Migration):
dependencies = [
("swh_web_common", "0004_auto_20190204_1324"),
]
operations = [migrations.RunPython(_remove_duplicated_urls_in_authorized_list)]

File Metadata

Mime Type
text/x-python
Expires
Fri, Jul 4, 1:52 PM (3 d, 15 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3240716

Event Timeline