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

Credits: migration performance

parent 0955d769
......@@ -6,17 +6,15 @@ import django.db.models.deletion
def populate_track_credit(apps, schema_editor):
from funkwhale_api.music.models import Credit
TrackCredit = apps.get_model("music", "TrackCredit")
Track = apps.get_model("music", "Track")
for tk in Track.objects.all():
tc = TrackCredit()
tc.artist = tk.artist
tc.track = tk
tc.credit = Credit.MAIN
tc.save()
tracks = Track.objects.values('artist__id', 'id').iterator()
credits = [
TrackCredit(artist_id=track['artist__id'], track_id=track['id'], credit="main")
for track in tracks
]
TrackCredit.objects.bulk_create(credits)
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