dr.botzo/markov/migrations/0006_link_markovtarget_to_i...

25 lines
765 B
Python

"""Generated by Django 3.2.18 on 2023-02-19 23:15."""
from django.db import migrations
def link_markovcontext_to_ircchannel(apps, schema_editor):
"""Link the markov targets to a hopefully matching channel, by name."""
IrcChannel = apps.get_model('ircbot', 'IrcChannel')
MarkovTarget = apps.get_model('markov', 'MarkovTarget')
for target in MarkovTarget.objects.all():
channel = IrcChannel.objects.get(name=target.name)
target.channel = channel
target.save()
class Migration(migrations.Migration):
"""Populate the markov target to IRC channel link."""
dependencies = [
('markov', '0005_markovtarget_channel'),
]
operations = [
migrations.RunPython(link_markovcontext_to_ircchannel)
]