# Generated by Django 4.2.26 on 2025-12-15 10:29

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


def set_default_product_tour_to_false():
    return {
        "work_items": False,
        "cycles": False,
        "modules": False,
        "intake": False,
        "pages": False,
    }

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


def populate_product_tour(apps, _schema_editor):
    WorkspaceUserProperties = apps.get_model('db', 'WorkspaceUserProperties')
    default_value = get_default_product_tour()
    # Use bulk update for better performance
    WorkspaceUserProperties.objects.all().update(product_tour=default_value)


class Migration(migrations.Migration):

    dependencies = [
        ('db', '0112_auto_20251124_0603'),
    ]

    operations = [
        migrations.AddField(
            model_name='webhook',
            name='version',
            field=models.CharField(default='v1', max_length=50),
        ),
        migrations.AddField(
            model_name='profile',
            name='is_navigation_tour_completed',
            field=models.BooleanField(default=False),
        ),
        migrations.AddField(
            model_name='workspaceuserproperties',
            name='product_tour',
            field=models.JSONField(default=set_default_product_tour_to_false),
        ),
         migrations.AddField(
            model_name='apitoken',
            name='allowed_rate_limit',
            field=models.CharField(default='60/min', max_length=255),
        ),
         migrations.AddField(
            model_name='profile',
            name='is_subscribed_to_changelog',
            field=models.BooleanField(default=False),
        ),
        migrations.RunPython(populate_product_tour, reverse_code=migrations.RunPython.noop),
    ]
