# Generated by Django 4.2.11 on 2024-06-03 17:16

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


def populate_views_owned_by(apps, schema_editor):
    IssueView = apps.get_model("db", "IssueView")

    # update all existing views to be owned by the user who created them
    IssueView.objects.update(owned_by_id=F("created_by_id"))


class Migration(migrations.Migration):

    dependencies = [
        ('db', '0068_remove_pagelabel_project_remove_pagelog_project_and_more'),
    ]

    operations = [
        migrations.AlterField(
            model_name="account",
            name="provider",
            field=models.CharField(
                choices=[
                    ("google", "Google"),
                    ("github", "Github"),
                    ("gitlab", "GitLab"),
                ]
            ),
        ),
        migrations.AlterField(
            model_name="socialloginconnection",
            name="medium",
            field=models.CharField(
                choices=[
                    ("Google", "google"),
                    ("Github", "github"),
                    ("GitLab", "gitlab"),
                    ("Jira", "jira"),
                ],
                default=None,
                max_length=20,
            ),
        ),
        migrations.AddField(
            model_name="issueview",
            name="is_locked",
            field=models.BooleanField(default=False),
        ),
        migrations.AddField(
            model_name="issueview",
            name="owned_by",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="views",
                to=settings.AUTH_USER_MODEL,
                null=True,
            ),
        ),
        migrations.RunPython(populate_views_owned_by),
        migrations.AlterField(
            model_name="issueview",
            name="owned_by",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="views",
                to=settings.AUTH_USER_MODEL,
            ),
        ),
    ]
