# Generated by Django 2.2.9 on 2020-02-07 11:21

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models

import waldur_rancher.models


class Migration(migrations.Migration):

    dependencies = [
        ('structure', '0010_customer_geolocation'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('waldur_rancher', '0009_runtime_state'),
    ]

    operations = [
        migrations.CreateModel(
            name='RancherUser',
            fields=[
                (
                    'id',
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name='ID',
                    ),
                ),
                ('backend_id', models.CharField(blank=True, max_length=255)),
                ('is_active', models.BooleanField(default=True)),
            ],
        ),
        migrations.CreateModel(
            name='RancherUserClusterLink',
            fields=[
                (
                    'id',
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name='ID',
                    ),
                ),
                ('backend_id', models.CharField(blank=True, max_length=255)),
                (
                    'role',
                    waldur_rancher.models.ClusterRole(
                        choices=[
                            ('owner', 'Cluster owner'),
                            ('owner', 'Cluster member'),
                        ],
                        db_index=True,
                        max_length=30,
                    ),
                ),
                (
                    'cluster',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to='waldur_rancher.Cluster',
                    ),
                ),
                (
                    'user',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to='waldur_rancher.RancherUser',
                    ),
                ),
            ],
            options={'unique_together': {('user', 'cluster', 'role')},},
        ),
        migrations.AddField(
            model_name='rancheruser',
            name='clusters',
            field=models.ManyToManyField(
                through='waldur_rancher.RancherUserClusterLink',
                to='waldur_rancher.Cluster',
            ),
        ),
        migrations.AddField(
            model_name='rancheruser',
            name='settings',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.PROTECT,
                to='structure.ServiceSettings',
            ),
        ),
        migrations.AddField(
            model_name='rancheruser',
            name='user',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL
            ),
        ),
        migrations.AlterUniqueTogether(
            name='rancheruser', unique_together={('user', 'settings')},
        ),
    ]
