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

from vbv_lernwelt.core.model_utils import add_organisations, remove_organisations


class Migration(migrations.Migration):
    dependencies = [
        ("core", "0002_joblog"),
    ]

    operations = [
        migrations.CreateModel(
            name="Organisation",
            fields=[
                (
                    "organisation_id",
                    models.IntegerField(primary_key=True, serialize=False),
                ),
                ("name_de", models.CharField(max_length=255)),
                ("name_fr", models.CharField(max_length=255)),
                ("name_it", models.CharField(max_length=255)),
            ],
            options={
                "verbose_name": "Organisation",
                "verbose_name_plural": "Organisations",
                "ordering": ["organisation_id"],
            },
        ),
        migrations.AddField(
            model_name="user",
            name="organisation",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                to="core.organisation",
            ),
        ),
        migrations.RunPython(add_organisations, remove_organisations),
    ]
