Commit 40567d3b authored by Auri's avatar Auri
Browse files

Credits: migration performance

parent 0955d769
...@@ -6,17 +6,15 @@ import django.db.models.deletion ...@@ -6,17 +6,15 @@ import django.db.models.deletion
def populate_track_credit(apps, schema_editor): def populate_track_credit(apps, schema_editor):
from funkwhale_api.music.models import Credit
TrackCredit = apps.get_model("music", "TrackCredit") TrackCredit = apps.get_model("music", "TrackCredit")
Track = apps.get_model("music", "Track") Track = apps.get_model("music", "Track")
for tk in Track.objects.all(): tracks = Track.objects.values('artist__id', 'id').iterator()
tc = TrackCredit() credits = [
tc.artist = tk.artist TrackCredit(artist_id=track['artist__id'], track_id=track['id'], credit="main")
tc.track = tk for track in tracks
tc.credit = Credit.MAIN ]
tc.save() TrackCredit.objects.bulk_create(credits)
def rewind(apps, schema_editor): def rewind(apps, schema_editor):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment