# Generated by Django 2.1 on 2019-05-23 16:08

from django.db import migrations, models


def set_default_exchange(apps, schema_editor):
    # We get the model from the versioned app registry
    # if we directly import it, it'll be the wrong version
    Remote = apps.get_model('remotes', 'Remote')
    db_alias = schema_editor.connection.alias
    for r in Remote.objects.using(db_alias).all():
        r.exchange = f'federated.{r.namespace}'
        r.save()


class Migration(migrations.Migration):
    dependencies = [
        ('remotes', '0001_initial'),
    ]

    operations = [
        migrations.AddField(
            model_name='remote',
            name='exchange',
            field=models.CharField(max_length=255, null=True),
        ),
        migrations.RunPython(set_default_exchange, migrations.RunPython.noop),
    ]
