# Generated by Django 4.2.27 on 2026-01-23 09:27

from django.db import migrations, models
import pi_dash.db.models.user

def set_getting_started_checklist():
 return {
        "project_created": True,
        "project_joined": True,
        "work_item_created": True,
        "team_members_invited": True,
        "page_created": True,
        "ai_chat_tried": True,
        "integration_linked": True,
        "view_created": True,
        "sticky_created": True,
    }
    
def set_default_tips():
    return {"mobile_app_download": True}


def set_default_explored_features():
    return {"github_integrated": True, "slack_integrated": True, "ai_chat_tried": True}


def set_default_product_tour():
    return {
        "work_items": True,
        "cycles": True,
        "modules": True,
        "intake": True,
        "pages": True,
    }


def migrate_all_the_product_tour_to_true(apps, _schema_editor):
    Profile = apps.get_model('db', 'Profile')
    WorkspaceMember = apps.get_model('db', 'WorkspaceMember')
    
    default_checklist_values = set_getting_started_checklist()
    default_tips_values = set_default_tips()        
    default_explored_features = set_default_explored_features()
    default_product_tour = set_default_product_tour()

    Profile.objects.all().update(is_navigation_tour_completed=True)
    WorkspaceMember.objects.all().update(getting_started_checklist=default_checklist_values)
    WorkspaceMember.objects.all().update(tips=default_tips_values)
    WorkspaceMember.objects.all().update(explored_features=default_explored_features)
    Profile.objects.all().update(product_tour=default_product_tour)


class Migration(migrations.Migration):

    dependencies = [
        ('db', '0117_rename_description_draftissue_description_json_and_more'),
    ]

    operations = [
        migrations.RemoveField(
            model_name='workspaceuserproperties',
            name='product_tour',
        ),
        migrations.AddField(
            model_name='profile',
            name='product_tour',
            field=models.JSONField(default=pi_dash.db.models.user.get_default_product_tour),
        ),
        migrations.RunPython(migrate_all_the_product_tour_to_true, reverse_code=migrations.RunPython.noop)

    ]
